From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 30 05:31:23 2024 Received: (at submit) by debbugs.gnu.org; 30 Apr 2024 09:31:23 +0000 Received: from localhost ([127.0.0.1]:59279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1jpa-0000co-W4 for submit@debbugs.gnu.org; Tue, 30 Apr 2024 05:31:23 -0400 Received: from lists.gnu.org ([2001:470:142::17]:59974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1jpZ-0000ci-1F for submit@debbugs.gnu.org; Tue, 30 Apr 2024 05:31:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1jp7-0002Gp-NP for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2024 05:30:53 -0400 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1jp5-0003yL-OQ for bug-gnu-emacs@gnu.org; Tue, 30 Apr 2024 05:30:53 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 5038A1380E2D for ; Tue, 30 Apr 2024 05:30:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 30 Apr 2024 05:30:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1714469450; x=1714555850; bh=5Bgmi9XsETm/LrH8OdOtGJf4jklHCtqK ufMR8d0FV4A=; b=w3jP2zxjRq7sgml8f/s38H6jaRmHXzHadNdYEQaYBK0qPlWT IqZj8Ffx4VKOsv0g1l9FaicJEp/UnVygYxGwMYSKGB2VnhiJyR0UwaktOvd1TDA4 oaVo4G6Dl7ynnxDnYpsFIHIx/+xVNC54XDA0Mdc0+465EtWdQUc2/Ft8KPHQBcbw Aj3glUE1YfPZO6pcIspafrW2GlQu6HkilneU7N8wpTDZODwi7sRyvoeAbiomLvCy msCzx4vI2IIu7JLLwTt1aE6KC1GEv83arzFE4bjUIWbHS3Ah16WRH/8SV+mrAG+D /xzJ1FtwTDlclh38EFD8vSB0IVUPTieTjdax/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1714469450; x=1714555850; bh=5Bgmi9XsETm/LrH8OdOtGJf4jklHCtqKufM R8d0FV4A=; b=MA/YjIfzJeeIL0gdh3Bb6F+RW2Q+3/nQSnJCZp0MMG/jFnAe59J pab3FE1NIC9iO1yliZyHGvmF5aYNmfrKfeQJFtOFRTDOnYbgDMKSnYLVq1vg+Q1j pxJsp8utZThZMtTrh8RYvPEH7Iy46VYP+h0OmQguVi7H/9nG+zIJGDKylXAB2vzC vAB32shi1DyKdWdgk0ZjcPH8KumyEupyFFu2CFMP7DBNRabJjJFrL/n8yw7gXV2c a8J2D5yNqGAnKuIW0N6QsbLQLLPAf9d2fn4sPnKLBaSCGF2dDP9OriUh4Y62zezr ZNHTKUm2JHftOLtsTXtum+S2vBY3PydH/GQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddufedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufgffkfggtgesthdtredttd ertdenucfhrhhomheplfhoohhsthcumfhrvghmvghrshcuoehjohhoshhtkhhrvghmvghr shesfhgrshhtmhgrihhlrdhfmheqnecuggftrfgrthhtvghrnhephfevffejhfegueffge eivdehheefudehudffgedtjedujeehveehffffkefhffeknecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrg hsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: ie15541ac:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 30 Apr 2024 05:30:49 -0400 (EDT) From: Joost Kremers To: bug-gnu-emacs@gnu.org Subject: 29.3; vtable-insert-object cannot insert at top of table User-Agent: mu4e 1.12.2; emacs 29.3 Date: Tue, 30 Apr 2024 11:30:47 +0200 Message-ID: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=103.168.172.151; envelope-from=joostkremers@fastmail.fm; helo=fout8-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) The current implementation of `vtable.el` provides the function `vtable-insert-object` to add an object to the vtable. Its signature is this: vtable-insert-object table object &optional after-object The doc string says that if AFTER-OBJECT is not provided, the new object is added to the end of the table. This makes it impossible to add an object as the first element of the table. Note that although this e-mail is written from Emacs 29.3, the version of `vtable.el` in master has the same problem. [All the diagnostic info that `M-x report-emacs-bug` usually gathers should appear here, but there was a problem with the buffer being read-only. I'll have to look into that, but for this report, this info isn't relevant, I think.] TIA -- Joost Kremers Life has its moments From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 30 08:19:24 2024 Received: (at 70664) by debbugs.gnu.org; 30 Apr 2024 12:19:24 +0000 Received: from localhost ([127.0.0.1]:59420 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1mSC-0002gf-EB for submit@debbugs.gnu.org; Tue, 30 Apr 2024 08:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1mS8-0002gZ-2Z for 70664@debbugs.gnu.org; Tue, 30 Apr 2024 08:19:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1mRi-0008Ls-3P; Tue, 30 Apr 2024 08:18:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=L8YA71mss3hfHOSkAw8covAO0sjQQYSGAVP16WjFfKk=; b=B97S3gQasfZs M8jkpUsRBJXyM52sDgZ+CGBPvAYB2ZniRzco+xsMblgMo0k9N/cYFndZHdC7GnbgjFHDxyvnQvZgB 9gr0rDLhVhxieWY535Y6f/Ytt9gtjWjfwMZRiSJcezqFuONWuV4fm4GRgM+sHHdeOgy+eNeLOgliZ AD0enfOPlEnE77wDG8Ec3zxb3wSpRppkEiJ9jsLWvp6boFojnVBi0l5PKxeWkR7FrQSi4z4anufw0 ZR7+6/3daVuOGAzGvsHgEr/b1hxlbUA8ke5HyYaHJTMhnh2fEAIReOaF052CH0mhtolf/z1Jepjt7 7iex0hxe28xZjrFY1dXXKQ==; Date: Tue, 30 Apr 2024 15:18:48 +0300 Message-Id: <864jbjqc0n.fsf@gnu.org> From: Eli Zaretskii To: Joost Kremers , Adam Porter In-Reply-To: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> (message from Joost Kremers on Tue, 30 Apr 2024 11:30:47 +0200) Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70664 Cc: 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Joost Kremers > Date: Tue, 30 Apr 2024 11:30:47 +0200 > > The current implementation of `vtable.el` provides the function > `vtable-insert-object` to add an object to the vtable. Its signature is this: > > vtable-insert-object table object &optional after-object > > The doc string says that if AFTER-OBJECT is not provided, the new object is > added to the end of the table. This makes it impossible to add an object as the > first element of the table. > > Note that although this e-mail is written from Emacs 29.3, the version of > `vtable.el` in master has the same problem. Adam, WDYT? You did something similar with vtable-update-object, AFAIR. From debbugs-submit-bounces@debbugs.gnu.org Thu May 02 02:52:43 2024 Received: (at 70664) by debbugs.gnu.org; 2 May 2024 06:52:43 +0000 Received: from localhost ([127.0.0.1]:41936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2QJ8-0007O8-P5 for submit@debbugs.gnu.org; Thu, 02 May 2024 02:52:43 -0400 Received: from fout4-smtp.messagingengine.com ([103.168.172.147]:52421) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2QJ7-0007O2-KO for 70664@debbugs.gnu.org; Thu, 02 May 2024 02:52:42 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id CD9571380394; Thu, 2 May 2024 02:52:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 02 May 2024 02:52:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1714632734; x=1714719134; bh=n8RxCg8pPf tVdzP2DxwkxH8bje5bxWOzBXJ1y0NrtZA=; b=Ki6h5KvV+mpfo7DPKuGjTOODzg MddQtwMKyTpTf0xuKDPwatW45/QCpP1wT5b8VUjnx5U/Z334/IJwRlI14xBcQFUt n/KwLm4vpK3J/Vr5NIwIDGmulBgIg41RZPHc52fYFhn95BDRUZEWBGCVuDxTXbDv 8kZ/1v1TsHqpNLRIc33LD1bkJ2KuWtvU6q6pRmtzvm1aYgZ0J41xR/q3xG7pA5v2 kWj2HI11Tyy1Wyd6jx/RpdHaxCqplyeLVyC1ukctTP+eUQP34xYikXGIsZNeSa5M AxAZLjpwwxLwyB2RD2I0ZMakuDJMJb+2TzeRCSQVTK9V06sLiQNQA+UGYw9A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1714632734; x=1714719134; bh=n8RxCg8pPftVdzP2DxwkxH8bje5b xWOzBXJ1y0NrtZA=; b=ORysdkSpwmVBjXDCk+zblkK+6YUKDVhoHwr0UYETqw50 KeKxgVwYruKpW7JSOmsJ7wGF979nuRu7cB0E5wRxat+fbNMyHdQIcRaTc8gzV1xz g7weJ+PdIHYFKC1IgvQf6XQd1znZiqypO4d/QmpnbI5epWUttTLFHf5RfL4s6PrF 0o130hRFUbVux1UgIHPZqNYKv3oqPUCRTmePM9KJ8KC+RMd/6hP0yS4DZ7evodeu xUa4f8aqSOdPDHqBPDJYQHoFegz3HJxafb2LDIjs+9yPlRC2IP7N84sGdqzZ8FZt QxRA64fSmXybFxpoT0laYKbZbMKVVBGIqMUWYbfvdQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddujedgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufgjfhgffffkgggtsehttdertddtredtnecuhfhrohhmpeflohho shhtucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfh hmqeenucggtffrrghtthgvrhhnpeefkeejgffftdfgffejudeukeetheduhfevtefhhfeh iefhledtgffhgeekiedvheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: ie15541ac:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 2 May 2024 02:52:13 -0400 (EDT) From: Joost Kremers To: Adam Porter Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table In-Reply-To: (Adam Porter's message of "Tue, 30 Apr 2024 18:27:26 -0500") References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> User-Agent: mu4e 1.12.2; emacs 29.3 Date: Thu, 02 May 2024 08:52:08 +0200 Message-ID: <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 70664 Cc: Eli Zaretskii , 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi Adam, On Tue, Apr 30 2024, Adam Porter wrote: > Hm, yes, it seems that it's not possible with the current implementation. > > My first idea, requiring maybe the smallest change to the code and no change to > the signature, would be to accept a special value as the AFTER-OBJECT argument > to indicate that it should be inserted as the first element, e.g. > `:insert-first'. My initial thought as well. > Alternatively, an additional BEFORE-OBJECT argument could be added, which would > probably require more changes to the code. I thought about this and a few other options that came to mind, but I don't think there's any option that's worth the additional effort to implement it. -- Joost Kremers Life has its moments From debbugs-submit-bounces@debbugs.gnu.org Thu May 02 05:55:15 2024 Received: (at 70664) by debbugs.gnu.org; 2 May 2024 09:55:15 +0000 Received: from localhost ([127.0.0.1]:42759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2T9Y-0006Lu-QB for submit@debbugs.gnu.org; Thu, 02 May 2024 05:55:15 -0400 Received: from eastern.birch.relay.mailchannels.net ([23.83.209.55]:8357) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2T9X-0006Lo-24 for 70664@debbugs.gnu.org; Thu, 02 May 2024 05:55:00 -0400 X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id AEA296C16F3; Thu, 2 May 2024 09:54:35 +0000 (UTC) Received: from pdx1-sub0-mail-a245.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3E7A86C16C7; Thu, 2 May 2024 09:54:35 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1714643675; a=rsa-sha256; cv=none; b=vcK2wnPkpy/K08ET9PjC9ygZl/ulueSdqOL/Q4r0FZLccIfUX+eBUGg9AiCYNnATDGzF1V te2q4Iv9m6USuv3pMr36aYrvKDS3yGMvDKgZBiRRSdrHV59/kL9uSzz3E0So8/VOnWZ2VC miMmwrFbuT8DCwNwFQ5ITllhnl/+3vNLQEy7fjKzSEPzR57oDKmxM1yYcwRgHskXxTOYUP b9fAN2HDohBMds1oI+MlZWZcB9Ba3nM8SKXhib27UETQgCIdd4RcqtLmzGQEIVVN3jfKkr b5XHQfQ1wQ76xPp6nsMcN10vSn42QRHs2Qj32yE37tjH9r7mkKDTtIseju80mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1714643675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=79q0X3IQQfoJwssMW4d/oErNNgMqBLJXS6u3sOdYqvw=; b=y9MspthiL0JNn6Jf6E6b5aHheVpjWfbMsKakm+1bmmxwsU+ibOG+MhmZtpPiCuxgILk+HU d8qQ6FqGIj7NMC/pwsHomWToVjAih48IrpwvlSILuaDieRu0y0A2aeXnv4JpVarmXm0NVG fIMMvW52m5EBKhgxt8CP+Utd4VLP3DA29GFqnL9ShzHy/NiC3j2Sy9nR8JSENXBgF5Wdy2 fIxeo2v9XJ3FvMCFoIQdI2KbWWbc67Lf2d40RKI9spsHtbMb22BN3Juwoy3786HxTWNzrC vwQAw79BtVWRCmjww6zdEEIYQMycDSK6OvLHAp9t0MdccQ0oAAbUe1EfSHkC2A== ARC-Authentication-Results: i=1; rspamd-67db6f49c6-98rkc; auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@alphapapa.net X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|adam@alphapapa.net X-MailChannels-Auth-Id: dreamhost X-Inform-Spicy: 3b5af380534031bb_1714643675500_2803388879 X-MC-Loop-Signature: 1714643675499:2566684977 X-MC-Ingress-Time: 1714643675499 Received: from pdx1-sub0-mail-a245.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.105.11.149 (trex/6.9.2); Thu, 02 May 2024 09:54:35 +0000 Received: from [10.45.0.54] (unknown [45.131.192.7]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adam@alphapapa.net) by pdx1-sub0-mail-a245.dreamhost.com (Postfix) with ESMTPSA id 4VVTmp4xFTzDX; Thu, 2 May 2024 02:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net; s=dreamhost; t=1714643675; bh=79q0X3IQQfoJwssMW4d/oErNNgMqBLJXS6u3sOdYqvw=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=sPDlIdeE4mciQzF7vvw/elZpNaEt5fvFN5YKSnaOtbEbxPyo6WOPuY+POPgnw3Usp /njCcNwk/7zLwgzOtCQpgK0SI028BmkQTxloTx38jW/TfSw1PuR86B6tM7WbnTj5ub lF3nXQP2cd+q95Ve8mNvt3sJFbYj+PViYLsv1dQKaVs48phERNd8DOLbw4BSxIfXRH telgR85hied5KH8itZMApjR245ibmi2Bt0mXnPS6G8BpOLSEzFiOn3IXC5MtNTVRr4 mN3d5+pdDbTPE7gfZLXP7e9Im3dOYmbu/SZFBh6EjRUV8Dulj/TfxLeG6jA+Ui7Xu0 mDoF5A/LNlD6g== Message-ID: <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> Date: Thu, 2 May 2024 04:54:33 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table To: Joost Kremers References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> Content-Language: en-US From: Adam Porter In-Reply-To: <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 70664 Cc: Eli Zaretskii , 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) To be clear, I don't plan to work on this anytime soon. :) Having said that, using a special value for AFTER-OBJECT to insert first would probably be a good idea, because it seems like it should be possible to do that, and it wouldn't require changing the signature. Beyond that, IMHO it might be good to write a function with a different signature that would allow more flexibility, e.g. (cl-defun vtable-add (object table &key after before at) "Add OBJECT to TABLE at specified position. AFTER may be an object after which to insert it; or BEFORE may be an object before which to insert it; or AT may be an integer position at which to insert the object, 0 meaning first and -1 meaning last (only one of these three arguments should be given).") Then the old function could be deprecated. From debbugs-submit-bounces@debbugs.gnu.org Thu May 02 06:12:55 2024 Received: (at 70664) by debbugs.gnu.org; 2 May 2024 10:12:55 +0000 Received: from localhost ([127.0.0.1]:42843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2TQt-0006Xc-7j for submit@debbugs.gnu.org; Thu, 02 May 2024 06:12:55 -0400 Received: from fhigh2-smtp.messagingengine.com ([103.168.172.153]:54531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2TQq-0006XS-Pa for 70664@debbugs.gnu.org; Thu, 02 May 2024 06:12:53 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 9114C114011D; Thu, 2 May 2024 06:12:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 02 May 2024 06:12:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1714644745; x=1714731145; bh=ln3NyHQC8L tpG3eKvccW585ufJGlW6deOXaeqTb0CLY=; b=AOL+Kj8LuFW3s12dMP+MXLDFnZ sSa3y4bpC8rcHTxZamiJWMXo2nVMQXspJl+VGpJOyKMjDkJK6Zt8ryNZWI3BnLx5 f/yBxdiJKKvokwL3KmVmROupEYXV2SVg7XbFA0DM4teF1JnHD74dX6DWTKym5gjd IASN4pBidMOgOVdhp3/1fpdNfi0Go1VY4EbjjIlM8cvSfPvHkfs8uh7cWSpsAhtP ams6eLzuy80yuIaC/gRENcVjwSfXECe/ioqPBOTmvtnQ4FlaELwtkQ/SgFCyHcRk BjGFnxfaAiTevhkWpHPOsuiS9XjREZYMFnRzuttjE8Oobg2ovHqWSfevgNaQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1714644745; x=1714731145; bh=ln3NyHQC8LtpG3eKvccW585ufJGl W6deOXaeqTb0CLY=; b=cYLQqklaGtFilSE+QP13hRoHBbvNivAZJdN4G/p9w9AZ CC3dYwawh1W+zLEkzcsbXVUKVM1OKHo8RW1omlB7VcWH/LyDSpg5kohsAJOUjuyO OQ/n7j3JNq3gO6DXJgu/MadrIyY/THmlBFJKUsidVC8xcr9dHYnGTuhjErrW9RUY I76aVxJC6Sxvd8eCmtNuDpoY3LtGvIXynLRKE2zYYUR4vO3H45+A/eNxXG+Cc6c8 S3jVgGfM9qC48MzX30ErpvRWWKYh3VJskopL4Y3P01S6RoikFroC4Cvis83qFA1I IPRVtc5bCv5K6yh8XqWqCvSE9W65qfPHLa0ZLXE6eA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddukedgvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffgffkfggtgesthdtredttdertdenucfhrhhomheplfhoohhs thcumfhrvghmvghrshcuoehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh eqnecuggftrfgrthhtvghrnhepfeekjefgffdtgfffjeduueekteehudfhveethffhheei hfeltdfghfegkeeivdehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: ie15541ac:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 2 May 2024 06:12:24 -0400 (EDT) From: Joost Kremers To: Adam Porter Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table In-Reply-To: <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> (Adam Porter's message of "Thu, 2 May 2024 04:54:33 -0500") References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> User-Agent: mu4e 1.12.2; emacs 29.3 Date: Thu, 02 May 2024 12:12:21 +0200 Message-ID: <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 70664 Cc: Eli Zaretskii , 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Thu, May 02 2024, Adam Porter wrote: > To be clear, I don't plan to work on this anytime soon. :) No problem. I would kinda like to give it a try myself, but I'm not going to make any promises, either. :-) > Beyond that, IMHO it might be good to write a function with a different > signature that would allow more flexibility, e.g. > > (cl-defun vtable-add (object table &key after before at) > "Add OBJECT to TABLE at specified position. > AFTER may be an object after which to insert it; or BEFORE may be an object > before which to insert it; or AT may be an integer position at which to insert > the object, 0 meaning first and -1 meaning last (only one of these three > arguments should be given).") I personally don't like the "only one of these three arguments should be given" part (what happens if more than one are given?), so perhaps a different suggestion: (defun vtable-add (object table &optional position before) ...) with POSITION being either an object or an integer. If an object, BEFORE being non-nil would mean "insert before POSITION", and nil would mean "insert after POSITION"). If POSITION is an integer, BEFORE is simply ignored. (With this signature, vtable-insert-object could actually be aliased to vtable-add.) Though I admit your suggestion has the advantage of explicit keywords. Do let me know which approach you prefer, in case I do decide to give it a try. -- Joost Kremers Life has its moments From debbugs-submit-bounces@debbugs.gnu.org Fri May 03 00:16:37 2024 Received: (at 70664) by debbugs.gnu.org; 3 May 2024 04:16:37 +0000 Received: from localhost ([127.0.0.1]:46104 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2kLc-0003WB-Pe for submit@debbugs.gnu.org; Fri, 03 May 2024 00:16:37 -0400 Received: from tiger.tulip.relay.mailchannels.net ([23.83.218.248]:47443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2kLZ-0003W5-3N for 70664@debbugs.gnu.org; Fri, 03 May 2024 00:16:35 -0400 X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id BD65B942016; Fri, 3 May 2024 04:16:09 +0000 (UTC) Received: from pdx1-sub0-mail-a239.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 584CD941B54; Fri, 3 May 2024 04:16:09 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1714709769; a=rsa-sha256; cv=none; b=pU2z9TDl11HKAgaBuV8ikGxWeaFqVAAgjAfvvAFu1p7HCZenBGKxeH66sVrJ138hYJ2Xix TQ7i7/qikH2GjuNocEi79hCdAhFUQV8GwtVMuNmjphCEqhK84qrpNbaisLEgpLuoFBgVRr ZrGkv5+y01TSQnuw+vLKOP7L8OF+SHsdU5HxE3w2QA/buv1OVrw4FXUCUI4EshfmvwLkiF S18elAts3DL5KAbnmlP+2CAX8DJTIUjATGppU2Op3/WypLJxLZTpHvKzGKqpH7tQL3V/wr ZoEukWXt8I5T+RG1qCqbXVjxru7vYztZALfDqvmkAiEdPlwocf6o8cb191vgFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1714709769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WiLwG18s4VUvb4/DA4UfnsSKglinv0zKgLb4HHoRjg8=; b=i/InIE6Qa3m5ZODJ8YvvmCK43TpNKko+evNTOzwCaU7UMvbAFZt9UucZjdI+IxPZNS0fSD e3RW6XC2XUqNso5gTCdHE9hYVEZW7JY29Cs9pZyEowtvGeNsaBGGtVQFDI9Tdf+FJS5MVG ywBh+0QVMYiVjUHV3lTrkGY4Qt1e2WtW6rNuD21+msQc/jeaVvdD0Iv5PAe4GIaxNVmUIu QRXVnQxqxpirJtXOCu1I6fmvE/dF3J+8GPQeJeulSDzIlOYJBtpkqnPQCMWLcu16dvZD5j WyjF/J+B/Msy8f9MAZu5IifOfbsT7APa4ZMzLfT5Ehukz4j8gwNTK87yzToTPA== ARC-Authentication-Results: i=1; rspamd-67db6f49c6-q7dv9; auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@alphapapa.net X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|adam@alphapapa.net X-MailChannels-Auth-Id: dreamhost X-Quick-Invention: 5e95fb0d6e13fea7_1714709769608_1302964637 X-MC-Loop-Signature: 1714709769608:2827314304 X-MC-Ingress-Time: 1714709769608 Received: from pdx1-sub0-mail-a239.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.120.191.7 (trex/6.9.2); Fri, 03 May 2024 04:16:09 +0000 Received: from [10.179.4.42] (unknown [45.130.83.1]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adam@alphapapa.net) by pdx1-sub0-mail-a239.dreamhost.com (Postfix) with ESMTPSA id 4VVyCr4dKGz9c; Thu, 2 May 2024 21:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net; s=dreamhost; t=1714709769; bh=WiLwG18s4VUvb4/DA4UfnsSKglinv0zKgLb4HHoRjg8=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=X6pBcH9DBNy9jGSLNrGktfFE0kXEgtT6WkNox/v7BOQkOqoKRDDAgHphE8NjwFtKf lLf9rIGYDAe31yHkhFh0mD0wG175a0+MwjyepCoX3zxKnVpk1sy738PJq9fDBw1MRc yZyumPZI9praBKQlZUY2QO3e01QaHlc3La7od6CCcKj05+dRFMEQjkD5rUO657HI0V Bb4Fw8kFGws0CjZxSNP6y4QRuxT0ate97B2NoWDNjsSpGFcLw4lVPEf1eNxzaw3811 J3FAVgG7d/KZHPRKM57qTilw5qDnufg8j6Mk4EGK43kWn7Z4QMbxyZWDkjKtbM42Gp ucgQR1ta4rKJA== Message-ID: <9333046c-194c-4b59-895a-2bf8427a6135@alphapapa.net> Date: Thu, 2 May 2024 23:16:07 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table To: Joost Kremers References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> Content-Language: en-US From: Adam Porter In-Reply-To: <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 4.2 (++++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi Joost, On 5/2/24 05:12, Joost Kremers wrote: > On Thu, May 02 2024, Adam Porter wrote: >> To be clear, I don't plan to work on this anytime soon. :) > > No problem. I would kinda like to give it a try myself [...] Content analysis details: (4.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [45.130.83.1 listed in zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [23.83.218.248 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [23.83.218.248 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: 70664 Cc: Eli Zaretskii , 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 3.2 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi Joost, On 5/2/24 05:12, Joost Kremers wrote: > On Thu, May 02 2024, Adam Porter wrote: >> To be clear, I don't plan to work on this anytime soon. :) > > No problem. I would kinda like to give it a try myself [...] Content analysis details: (3.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [23.83.218.248 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [23.83.218.248 listed in list.dnswl.org] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [45.130.83.1 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager Hi Joost, On 5/2/24 05:12, Joost Kremers wrote: > On Thu, May 02 2024, Adam Porter wrote: >> To be clear, I don't plan to work on this anytime soon. :) > > No problem. I would kinda like to give it a try myself, but I'm not going to > make any promises, either. :-) Of course. :) >> Beyond that, IMHO it might be good to write a function with a different >> signature that would allow more flexibility, e.g. >> >> (cl-defun vtable-add (object table &key after before at) >> "Add OBJECT to TABLE at specified position. >> AFTER may be an object after which to insert it; or BEFORE may be an object >> before which to insert it; or AT may be an integer position at which to insert >> the object, 0 meaning first and -1 meaning last (only one of these three >> arguments should be given).") > > I personally don't like the "only one of these three arguments should be given" > part (what happens if more than one are given?), so perhaps a different > suggestion: > > (defun vtable-add (object table &optional position before) > ...) > > with POSITION being either an object or an integer. If an object, BEFORE being > non-nil would mean "insert before POSITION", and nil would mean "insert after > POSITION"). If POSITION is an integer, BEFORE is simply ignored. (With this > signature, vtable-insert-object could actually be aliased to vtable-add.) > > Though I admit your suggestion has the advantage of explicit keywords. > > Do let me know which approach you prefer, in case I do decide to give it a try. I generally like to use keywords for clarity when there are more than 3-4 arguments to a function (also to avoid the "nil nil t" patterns that sometimes happens without keywords). In this case, your idea is slightly less explicit, perhaps requiring more careful reading of the docstring, but is more compact, and could actually extend the signature of the existing vtable-insert-object function, which would seem good. So, IMHO, I'd suggest applying your idea to the existing vtable-insert-object function, i.e. repurposing its existing AFTER-OBJECT argument to your new after-object-or-position argument, and adding your new before-object-or-position argument (I use those names just here for clarity, of course). (And, BTW, having thought about it further, we should probably keep the order of the OBJECT and TABLE arguments as-is in vtable.) My two cents, anyway. :) Thanks, Adam From debbugs-submit-bounces@debbugs.gnu.org Tue May 07 06:53:37 2024 Received: (at 70664) by debbugs.gnu.org; 7 May 2024 10:53:37 +0000 Received: from localhost ([127.0.0.1]:42506 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4IS0-0008Qs-IW for submit@debbugs.gnu.org; Tue, 07 May 2024 06:53:37 -0400 Received: from wfout3-smtp.messagingengine.com ([64.147.123.146]:56217) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4IRw-0008Qi-3t for 70664@debbugs.gnu.org; Tue, 07 May 2024 06:53:35 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 27C6E1C00182; Tue, 7 May 2024 06:53:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 07 May 2024 06:53:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1715079180; x=1715165580; bh=jSrRmaYyd0 XTgZOy8BPnwa8svOsVcoAiADLGa0wsDuU=; b=S+oECVkQrv8xuybGIzT5Ll2C6u nPSbN/Lfo1DlLPWM3ACnbR+2uLe7lTBvi8wd9gbdX0JvjSLi1O9AKUFZ+01a9NwG +mK7iDj+cIunLyk3mFOMa4M7h4neLMm0S6N8veE1GMV8VN2liUUhklCQkL2dzXIt 6ew+zk8vs32Xwp0JNcnbg1wD4Gez5RSOZXPXMkY9cwwnNNqLVBFsXeeV/VPW0KED c6/X7/Sjud5NQnIJX68tg0cA5i0EKUu2WAl2DnJWzwZrgk43YOg65Tw3n5xFhobd +XPLMtzCA50kSx1gM2pWJPlV7OGy4Dt1U/nEJk/T9SHO3LpBKgBgKfhTGD3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715079180; x=1715165580; bh=jSrRmaYyd0XTgZOy8BPnwa8svOsV coAiADLGa0wsDuU=; b=ZaS6cvzZlq2OZ9xE0Ia1xGITecnmPWt0MvclbUKS0UZL OliZmnv3G/Rt3aW0GHIDMKJvyBDfOo+NWT8lEXJ3fwjnq9l+noEIDvqib5uxZ64d /rFrOw9deLxPNE9qUUcbIfn6R0iYWAS0VW75YqqnDSBHY44NG0XEY10LWSOQreON mXMgtwzeRNsQnZl4c98Bz02+5q8Y5x++ZeqwQZXH/y4cVk9n41Kk3Qd2BdpfprZt m5RPyIWl++Tec0bZcWhF44926UkFxvseXPucm2oh2bJcbBRXDxjOQMxowLJUUz2Y wdrfs3vyovcsbt/ap8XccNryqbtSI7sFnB5PshpQTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvkedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffffkgggtsehmtderredttddtnecuhfhrohhmpeflohhoshht ucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhmqe enucggtffrrghtthgvrhhnpedvuedugffhtdevtddtledvleduleehheefveffgfdvheej vdeiieevkeejieekgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: ie15541ac:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 May 2024 06:52:59 -0400 (EDT) From: Joost Kremers To: Adam Porter Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table In-Reply-To: <9333046c-194c-4b59-895a-2bf8427a6135@alphapapa.net> (Adam Porter's message of "Thu, 2 May 2024 23:16:07 -0500") References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <9333046c-194c-4b59-895a-2bf8427a6135@alphapapa.net> Date: Tue, 07 May 2024 12:52:56 +0200 Message-ID: <868r0levw7.fsf@fastmail.fm> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 70664 Cc: Eli Zaretskii , 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Hi Adam, Eli, Here's my first attempt at fixing this bug and generally making `vtable-insert-object` more versatile (see attachment). A few questions / comments: - Is this the right place to send this patch? Or should it go to emacs-devel? - There are quite a few combinations of LOCATION and BEFORE to handle, which may make the code a bit hard to follow. A possible alternative would be to define some internal helper functions, `vtable--insert-before` and `vtable--insert-after`. You guys be the judge. (I added a few comments to hopefully make it clearer) - The patch also updates the documentation. Do check the style, though, my writing usually isn't so great. - I'm sure I made all sorts of mistakes with the commit message. - I don't know if this change warrants a NEWS entry. It's not really user-facing, so I didn't add one. - The current implementation of vtable-insert-object has a bug: it puts the object in the right location in the object list and the cache, but not in the buffer. This patch also fixes this bug. - I don't know how to write a non-interactive test for my changes, because `vtable-insert-object` only works if the vtable is being displayed in a buffer. So instead I wrote an interactive function to test all possible combinations of LOCATION and BEFORE: ```emacs-lisp (defun test-vtable-insert-object-interactive () "Test `vtable-insert-object'." (interactive) (let ((buffer (get-buffer-create " *vtable-test*"))) (pop-to-buffer buffer) (erase-buffer) (let* ((object1 '("Foo" 3)) (object2 '("Gazonk" 8)) (table (make-vtable :columns '("Name" (:name "Rank" :width 5)) :objects (list object1 object2)))) (mapc (lambda (args) (pcase-let ((`(,object ,location ,before) args)) (if (y-or-n-p (format "Update table with location = %s and before = %s?" location before)) (vtable-insert-object table object location before)))) `( ; Some correct inputs. ;; object location before (("Fizz" 4) ,object1 nil) (("Bop" 7) ,object2 t) (("Zat" 5) 2 nil) (("Dib" 6) 3 t) (("Wup" 9) nil nil) (("Quam" 2) nil t) ;; And some faulty inputs. (("Yat" 1) -1 nil) ; non-existing index, `before' is ignored. (("Vop" 10) 100 t) ; non-existing index, `before' is ignored. (("Jib" 11) ("Bleh" 0) nil) ; non-existing object. (("Nix" 0) ("Ugh" 0) t) ; non-existing object. )) (if (y-or-n-p "Regenerate table?") (vtable-revert))))) ``` The final table should have the "Rank" column sorted in ascending order (0-11). Regenerating the table should not change it. -- Joost Kremers Life has its moments --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-vtable-insert-object-more-versatile.patch >From d48020ff58ff9b2684365772a6161023d4ff22d5 Mon Sep 17 00:00:00 2001 From: Joost Kremers Date: Tue, 7 May 2024 11:52:27 +0200 Subject: [PATCH] Make vtable-insert-object more versatile Rename argument AFTER-OBJECT to LOCATION; allow use of index to refer to the insertion position; add argument BEFORE (Bug#70664). * lisp/emacs-lisp/vtable.el (vtable-insert-object): * doc/misc/vtable.texi (Interface Functions): Document the change. --- doc/misc/vtable.texi | 18 +++++-- lisp/emacs-lisp/vtable.el | 98 ++++++++++++++++++++++++++++++--------- 2 files changed, 89 insertions(+), 27 deletions(-) diff --git a/doc/misc/vtable.texi b/doc/misc/vtable.texi index dd5b70cf32f..82a12906e7a 100644 --- a/doc/misc/vtable.texi +++ b/doc/misc/vtable.texi @@ -548,10 +548,20 @@ Interface Functions table. @end defun -@defun vtable-insert-object table object &optional after-object -Insert @var{object} into @var{table}. If @var{after-object}, insert -the object after this object; otherwise append to @var{table}. This -also updates the displayed table. +@defun vtable-insert-object table object &optional location before +Insert @var{object} into @var{table}. @var{location} should be an +object in the table, the new object is inserted after this object, or +before it if @var{before} is non-nil. If @var{location} is nil, +@var{object} is appended to @var{table}, or prepended if @var{before} is +non-nil. + +@var{location} can also be an integer, a zero-based index into the +table. In this case, @var{object} is inserted at that index. If the +index is out of range, @var{object} is prepended to @var{table} if the +index is too small, or appended if it is too large. In this case, +@var{before} is ignored. + +This also updates the displayed table. @end defun @defun vtable-update-object table object &optional old-object diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el index d8e5136c666..b53df6743ea 100644 --- a/lisp/emacs-lisp/vtable.el +++ b/lisp/emacs-lisp/vtable.el @@ -348,19 +348,57 @@ vtable-remove-object (when (vtable-goto-object object) (delete-line))))) -(defun vtable-insert-object (table object &optional after-object) - "Insert OBJECT into TABLE after AFTER-OBJECT. -If AFTER-OBJECT is nil (or doesn't exist in the table), insert -OBJECT at the end. +;; FIXME: The fact that the `location' argument of +;; `vtable-insert-object' can be an integer and is then interpreted as +;; an index precludes the use of integers as objects. This seems a very +;; unlikely use-case, so let's just accept this limitation. + +(defun vtable-insert-object (table object &optional location before) + "Insert OBJECT into TABLE at LOCATION. +LOCATION is an object in TABLE. OBJECT is inserted after LOCATION, +unless BEFORE is non-nil, in which case it is inserted before LOCATION. + +If LOCATION is nil, or does not exist in the table, OBJECT is inserted +at the end of the table, or at the beginning if BEFORE is non-nil. + +LOCATION can also be an integer, a (zero-based) index into the table. +OBJECT is inserted at this location. If the index is out of range, +OBJECT is inserted at the beginning (if the index is less than 0) or +end (if the index is too large) of the table. BEFORE is ignored in this +case. + This also updates the displayed table." + ;; FIXME: Inserting an object into an empty vtable currently isn't + ;; possible. `nconc' fails silently (twice), and `setcar' on the cache + ;; raises an error. + (if (null (vtable-objects table)) + (error "[vtable] Cannot insert object into empty vtable")) ;; First insert into the objects. - (let (pos) - (if (and after-object - (setq pos (memq after-object (vtable-objects table)))) - ;; Splice into list. - (setcdr pos (cons object (cdr pos))) - ;; Append. - (nconc (vtable-objects table) (list object)))) + (let ((pos (if location + (if (integerp location) + (prog1 + (nthcdr location (vtable-objects table)) + ;; Do not prepend if index is too large: + (setq before nil)) + (or (memq location (vtable-objects table)) + ;; Prepend if `location' is not found and + ;; `before' is non-nil: + (and before (vtable-objects table)))) + ;; If `location' is nil and `before' is non-nil, we + ;; prepend the new object. + (if before (vtable-objects table))))) + (if (or before ; If `before' is non-nil, `pos' should be, as well. + (and pos (integerp location))) + ;; Add the new object before. + (let ((old-object (car pos))) + (setcar pos object) + (setcdr pos (cons old-object (cdr pos)))) + ;; Otherwise, add the object after. + (if pos + ;; Splice the object into the list. + (setcdr pos (cons object (cdr pos))) + ;; Otherwise, append the object. + (nconc (vtable-objects table) (list object))))) ;; Then adjust the cache and display. (save-excursion (vtable-goto-table table) @@ -372,19 +410,33 @@ vtable-insert-object 'face (vtable-face table)) "")) (ellipsis-width (string-pixel-width ellipsis)) - (elem (and after-object - (assq after-object (car cache)))) + (elem (if location ; This binding mirrors the binding of `pos' above. + (if (integerp location) + (nth location (car cache)) + (or (assq location (car cache)) + (and before (caar cache)))) + (if before (caar cache)))) + (pos (memq elem (car cache))) (line (cons object (vtable--compute-cached-line table object)))) - (if (not elem) - ;; Append. - (progn - (setcar cache (nconc (car cache) (list line))) - (vtable-end-of-table)) - ;; Splice into list. - (let ((pos (memq elem (car cache)))) - (setcdr pos (cons line (cdr pos))) - (unless (vtable-goto-object after-object) - (vtable-end-of-table)))) + (if (or before + (and pos (integerp location))) + ;; Add the new object before:. + (let ((old-line (car pos))) + (setcar pos line) + (setcdr pos (cons old-line (cdr pos))) + (unless (vtable-goto-object (car elem)) + (vtable-beginning-of-table))) + ;; Otherwise, add the object after. + (if pos + ;; Splice the object into the list. + (progn + (setcdr pos (cons line (cdr pos))) + (if (vtable-goto-object location) + (forward-line 1) ; Insert *after*. + (vtable-end-of-table))) + ;; Otherwise, append the object. + (setcar cache (nconc (car cache) (list line))) + (vtable-end-of-table))) (let ((start (point))) ;; FIXME: We have to adjust colors in lines below this if we ;; have :row-colors. -- 2.45.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu May 09 04:46:39 2024 Received: (at 70664) by debbugs.gnu.org; 9 May 2024 08:46:39 +0000 Received: from localhost ([127.0.0.1]:54054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4zQE-00058m-Ro for submit@debbugs.gnu.org; Thu, 09 May 2024 04:46:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54024) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4zQ9-00058W-O2 for 70664@debbugs.gnu.org; Thu, 09 May 2024 04:46:37 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4zPe-0003dO-7s; Thu, 09 May 2024 04:46:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=tIASZCgWOYiwnvQ4ceOHEFZ0mvjQvfhJCJB1C/Efums=; b=eLi/CQQgiUlF /S017AuYvQXoXFVNHdWVIN5wCXRi/VkDCiocODtsPSubJWogHKHSl7xiDAg8gm8krpVgjpSVl4cF+ MBcAzLIidJc7l5rJdt7nuzm1QNs7dm93YJ5bpyll2INlC/mMLSWxvkgyIulV8qEhnszsMTtz27hRr s6QETXEtQYVJtLo4HZUdRZZNSr+XG0gj2QJwe0rDn2H/SRHRU6rf1KfidRj/8jSDEyHDO0LjURBd0 HJS4+4VYvbKllriA8nQL1zU2YyKK1Wjiop2USvzRu+Gzt3Sz+2+oTE/uHAqOBX5v1xkQLFBVW3EhP ZmeMhqS8cKE31V1O5ybkAQ==; Date: Thu, 09 May 2024 11:45:57 +0300 Message-Id: <868r0j74qi.fsf@gnu.org> From: Eli Zaretskii To: Joost Kremers In-Reply-To: <868r0levw7.fsf@fastmail.fm> (message from Joost Kremers on Tue, 07 May 2024 12:52:56 +0200) Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <9333046c-194c-4b59-895a-2bf8427a6135@alphapapa.net> <868r0levw7.fsf@fastmail.fm> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70664 Cc: adam@alphapapa.net, 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Joost Kremers > Cc: Eli Zaretskii , 70664@debbugs.gnu.org > Date: Tue, 07 May 2024 12:52:56 +0200 > > Here's my first attempt at fixing this bug and generally making > `vtable-insert-object` more versatile (see attachment). Thanks. > A few questions / comments: > > - Is this the right place to send this patch? Or should it go to emacs-devel? Here is the right place for patches. > - I don't know if this change warrants a NEWS entry. It's not really > user-facing, so I didn't add one. This changes a public API, so it does need to be called out in NEWS, just in the section which lists Lisp-level changes. > - I don't know how to write a non-interactive test for my changes, because > `vtable-insert-object` only works if the vtable is being displayed in a > buffer. So instead I wrote an interactive function to test all possible > combinations of LOCATION and BEFORE: A test can be interactive (since the test suite can be run interactively as well), but then please skip the test if it's run in batch mode. > +@defun vtable-insert-object table object &optional location before > +Insert @var{object} into @var{table}. @var{location} should be an > +object in the table, the new object is inserted after this object, or > +before it if @var{before} is non-nil. If @var{location} is nil, ^^^ ^^^ @code{nil}, in both cases. > +;; FIXME: The fact that the `location' argument of > +;; `vtable-insert-object' can be an integer and is then interpreted as > +;; an index precludes the use of integers as objects. This seems a very ^^ Two spaces between sentences, please. From debbugs-submit-bounces@debbugs.gnu.org Thu May 09 12:46:35 2024 Received: (at 70664) by debbugs.gnu.org; 9 May 2024 16:46:35 +0000 Received: from localhost ([127.0.0.1]:56252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s56uh-0008CT-1H for submit@debbugs.gnu.org; Thu, 09 May 2024 12:46:35 -0400 Received: from fhigh7-smtp.messagingengine.com ([103.168.172.158]:51479) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s56ub-0008Bu-FU for 70664@debbugs.gnu.org; Thu, 09 May 2024 12:46:33 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 1CD711140078; Thu, 9 May 2024 12:45:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 09 May 2024 12:45:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1715273158; x=1715359558; bh=mf787H2ZYV co41GZc9cDO/B13rTd6yC9BTvw+wfkIM8=; b=0cLUA8DQn6uxA2AuOTMi4Tp6/q QiVsOVAO1Au4+QYuom4QBURMVWDIMRu1cBKRsTuryMwUrq/8FFsuQRA1bls+U+4e zO+kiq+CSh5sfO6dmngEPHzFIKStAcmU40deOrOaEp/xA+ftD2z+fSrO/PDK5RBr NzZF7O96OMdfXoJXS0NrVx/yL4VRmWOi8UwYgSR6LV3XhZpvj07k07p1EY/oMAkU F6sGg0Uw8tFDMw6r98QD1TA1nQLe0w1KTE5c6gXR6AXXDT4HDkMI28HINm1fu1g+ VVjxNVq0kesHPYBfxB5y4KNwOmmEOxqK6sLuwHQoKJ0ixDPVy+kSqAtZGaEQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715273158; x=1715359558; bh=mf787H2ZYVco41GZc9cDO/B13rTd 6yC9BTvw+wfkIM8=; b=Uwdil2dT+63Fjq1ifNiUjjTLxDJrak1MO4d1p3m2Y6f6 NPRX9Koi1zPTefXA3mOSBd0lyhwk2cGJyEx9P1ZD9oale4QkHnWsP8kZdx12wMs8 o1W/J3C9n2Sw8CcmjI3g2b+vyMdLNE25N1i43OfyxPgiJ/fNWiLc3zol34YtBBjQ cmBtX9Mm0hfx4+AqmDNAsFDbX2HGN1Xe9QJJ9/QWH04ma2hoapO69fPnpppjYZWm enE9iPQDXNkt/e50b3XTQVqo76dwPRn3gmIIR7JXWa8bmOqZSLeQtX0SCAxkZKoa zc15JJZXF81jNu8d2K7dnBDALOt6yhQp/YDo7aWg3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdefvddguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufgjfhffkfggtgesmhdtreertddttdenucfhrhhomheplfhoohhs thcumfhrvghmvghrshcuoehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh eqnecuggftrfgrthhtvghrnhepvdeuudfghfdtvedttdelvdeludelheehfeevfffgvdeh jedvieeiveekjeeikefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: ie15541ac:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 May 2024 12:45:56 -0400 (EDT) From: Joost Kremers To: Eli Zaretskii Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table In-Reply-To: <868r0j74qi.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 09 May 2024 11:45:57 +0300") References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <9333046c-194c-4b59-895a-2bf8427a6135@alphapapa.net> <868r0levw7.fsf@fastmail.fm> <868r0j74qi.fsf@gnu.org> Date: Thu, 09 May 2024 18:45:52 +0200 Message-ID: <861q6b7x33.fsf@fastmail.fm> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 70664 Cc: adam@alphapapa.net, 70664@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain On Thu, May 09 2024, Eli Zaretskii wrote: > This changes a public API, so it does need to be called out in NEWS, > just in the section which lists Lisp-level changes. OK, I added an entry, now contained in the new patch. > A test can be interactive (since the test suite can be run > interactively as well), but then please skip the test if it's run in > batch mode. Actually, once I took out the 'y-or-n-p' calls, it turned out the test runs fine non-interactively. I included it in the patch. > @code{nil}, in both cases. [...] > Two spaces between sentences, please. Done. Here's the new patch. -- Joost Kremers Life has its moments --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-vtable-insert-object-more-versatile.patch >From aacba116ee729663f078e8fb1fee2d0fee01a7a8 Mon Sep 17 00:00:00 2001 From: Joost Kremers Date: Tue, 7 May 2024 11:52:27 +0200 Subject: [PATCH] Make vtable-insert-object more versatile Rename argument AFTER-OBJECT to LOCATION; allow use of index to refer to the insertion position; add argument BEFORE (Bug#70664). * lisp/emacs-lisp/vtable.el (vtable-insert-object): * doc/misc/vtable.texi (Interface Functions): Document the change. --- doc/misc/vtable.texi | 18 +++-- etc/NEWS | 13 ++++ lisp/emacs-lisp/vtable.el | 98 +++++++++++++++++++++------- test/lisp/emacs-lisp/vtable-tests.el | 30 +++++++++ 4 files changed, 132 insertions(+), 27 deletions(-) diff --git a/doc/misc/vtable.texi b/doc/misc/vtable.texi index dd5b70cf32f..822b1097cd9 100644 --- a/doc/misc/vtable.texi +++ b/doc/misc/vtable.texi @@ -548,10 +548,20 @@ Interface Functions table. @end defun -@defun vtable-insert-object table object &optional after-object -Insert @var{object} into @var{table}. If @var{after-object}, insert -the object after this object; otherwise append to @var{table}. This -also updates the displayed table. +@defun vtable-insert-object table object &optional location before +Insert @var{object} into @var{table}. @var{location} should be an +object in the table, the new object is inserted after this object, or +before it if @var{before} is non-nil. If @var{location} is @code{nil}, +@var{object} is appended to @var{table}, or prepended if @var{before} is +non-@code{nil}. + +@var{location} can also be an integer, a zero-based index into the +table. In this case, @var{object} is inserted at that index. If the +index is out of range, @var{object} is prepended to @var{table} if the +index is too small, or appended if it is too large. In this case, +@var{before} is ignored. + +This also updates the displayed table. @end defun @defun vtable-update-object table object &optional old-object diff --git a/etc/NEWS b/etc/NEWS index e2588afeb40..6ed5bf12287 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2563,6 +2563,19 @@ this case, would mean repeating the object in the argument list.) When replacing an object with a different one, passing both the new and old objects is still necessary. +** 'vtable-insert-object' can insert "before" or at an index. +The signature of 'vtable-insert-object' has changed and is now: + +(vtable-insert-object table object &optional location before) + +'location' corresponds to the old 'after-object' argument; if 'before' +is non-nil, the new object is inserted before the 'location' object, +making it possible to insert a new object at the top of the +table. (Before, this was not possible.) In addition, 'location' can be +an integer, a (zero-based) index into the table at which the new object +is inserted ('before' is ignored in this case). + + ** JSON --- diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el index d8e5136c666..cb7ea397314 100644 --- a/lisp/emacs-lisp/vtable.el +++ b/lisp/emacs-lisp/vtable.el @@ -348,19 +348,57 @@ vtable-remove-object (when (vtable-goto-object object) (delete-line))))) -(defun vtable-insert-object (table object &optional after-object) - "Insert OBJECT into TABLE after AFTER-OBJECT. -If AFTER-OBJECT is nil (or doesn't exist in the table), insert -OBJECT at the end. +;; FIXME: The fact that the `location' argument of +;; `vtable-insert-object' can be an integer and is then interpreted as +;; an index precludes the use of integers as objects. This seems a very +;; unlikely use-case, so let's just accept this limitation. + +(defun vtable-insert-object (table object &optional location before) + "Insert OBJECT into TABLE at LOCATION. +LOCATION is an object in TABLE. OBJECT is inserted after LOCATION, +unless BEFORE is non-nil, in which case it is inserted before LOCATION. + +If LOCATION is nil, or does not exist in the table, OBJECT is inserted +at the end of the table, or at the beginning if BEFORE is non-nil. + +LOCATION can also be an integer, a (zero-based) index into the table. +OBJECT is inserted at this location. If the index is out of range, +OBJECT is inserted at the beginning (if the index is less than 0) or +end (if the index is too large) of the table. BEFORE is ignored in this +case. + This also updates the displayed table." + ;; FIXME: Inserting an object into an empty vtable currently isn't + ;; possible. `nconc' fails silently (twice), and `setcar' on the cache + ;; raises an error. + (if (null (vtable-objects table)) + (error "[vtable] Cannot insert object into empty vtable")) ;; First insert into the objects. - (let (pos) - (if (and after-object - (setq pos (memq after-object (vtable-objects table)))) - ;; Splice into list. - (setcdr pos (cons object (cdr pos))) - ;; Append. - (nconc (vtable-objects table) (list object)))) + (let ((pos (if location + (if (integerp location) + (prog1 + (nthcdr location (vtable-objects table)) + ;; Do not prepend if index is too large: + (setq before nil)) + (or (memq location (vtable-objects table)) + ;; Prepend if `location' is not found and + ;; `before' is non-nil: + (and before (vtable-objects table)))) + ;; If `location' is nil and `before' is non-nil, we + ;; prepend the new object. + (if before (vtable-objects table))))) + (if (or before ; If `before' is non-nil, `pos' should be, as well. + (and pos (integerp location))) + ;; Add the new object before. + (let ((old-object (car pos))) + (setcar pos object) + (setcdr pos (cons old-object (cdr pos)))) + ;; Otherwise, add the object after. + (if pos + ;; Splice the object into the list. + (setcdr pos (cons object (cdr pos))) + ;; Otherwise, append the object. + (nconc (vtable-objects table) (list object))))) ;; Then adjust the cache and display. (save-excursion (vtable-goto-table table) @@ -372,19 +410,33 @@ vtable-insert-object 'face (vtable-face table)) "")) (ellipsis-width (string-pixel-width ellipsis)) - (elem (and after-object - (assq after-object (car cache)))) + (elem (if location ; This binding mirrors the binding of `pos' above. + (if (integerp location) + (nth location (car cache)) + (or (assq location (car cache)) + (and before (caar cache)))) + (if before (caar cache)))) + (pos (memq elem (car cache))) (line (cons object (vtable--compute-cached-line table object)))) - (if (not elem) - ;; Append. - (progn - (setcar cache (nconc (car cache) (list line))) - (vtable-end-of-table)) - ;; Splice into list. - (let ((pos (memq elem (car cache)))) - (setcdr pos (cons line (cdr pos))) - (unless (vtable-goto-object after-object) - (vtable-end-of-table)))) + (if (or before + (and pos (integerp location))) + ;; Add the new object before:. + (let ((old-line (car pos))) + (setcar pos line) + (setcdr pos (cons old-line (cdr pos))) + (unless (vtable-goto-object (car elem)) + (vtable-beginning-of-table))) + ;; Otherwise, add the object after. + (if pos + ;; Splice the object into the list. + (progn + (setcdr pos (cons line (cdr pos))) + (if (vtable-goto-object location) + (forward-line 1) ; Insert *after*. + (vtable-end-of-table))) + ;; Otherwise, append the object. + (setcar cache (nconc (car cache) (list line))) + (vtable-end-of-table))) (let ((start (point))) ;; FIXME: We have to adjust colors in lines below this if we ;; have :row-colors. diff --git a/test/lisp/emacs-lisp/vtable-tests.el b/test/lisp/emacs-lisp/vtable-tests.el index 08fdf1594a4..1d4b0650210 100644 --- a/test/lisp/emacs-lisp/vtable-tests.el +++ b/test/lisp/emacs-lisp/vtable-tests.el @@ -39,4 +39,34 @@ test-vstable-compute-columns :insert nil))) '(left right left)))) +(ert-deftest test-vtable-insert-object () + (should + (equal (let ((buffer (get-buffer-create " *vtable-test*"))) + (pop-to-buffer buffer) + (erase-buffer) + (let* ((object1 '("Foo" 3)) + (object2 '("Gazonk" 8)) + (table (make-vtable + :columns '("Name" (:name "Rank" :width 5)) + :objects (list object1 object2)))) + (mapc (lambda (args) + (pcase-let ((`(,object ,location ,before) args)) + (vtable-insert-object table object location before))) + `( ; Some correct inputs. + ;; object location before + (("Fizz" 4) ,object1 nil) + (("Bop" 7) ,object2 t) + (("Zat" 5) 2 nil) + (("Dib" 6) 3 t) + (("Wup" 9) nil nil) + (("Quam" 2) nil t) + ;; And some faulty inputs. + (("Yat" 1) -1 nil) ; non-existing index, `before' is ignored. + (("Vop" 10) 100 t) ; non-existing index, `before' is ignored. + (("Jib" 11) ("Bleh" 0) nil) ; non-existing object. + (("Nix" 0) ("Ugh" 0) t) ; non-existing object. + )) + (mapcar #'cadr (vtable-objects table)))) + (number-sequence 0 11)))) + ;;; vtable-tests.el ends here -- 2.45.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 18 04:54:46 2024 Received: (at 70664-done) by debbugs.gnu.org; 18 May 2024 08:54:46 +0000 Received: from localhost ([127.0.0.1]:60415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8Fq2-0008AW-6c for submit@debbugs.gnu.org; Sat, 18 May 2024 04:54:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45088) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8Fpu-0008AG-Bq for 70664-done@debbugs.gnu.org; Sat, 18 May 2024 04:54:43 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8Fpl-0007FG-Gc; Sat, 18 May 2024 04:54:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=hkP1v2MSLFOl902PyLWvqPyq9QmZj+BEyu+kavmmBdg=; b=NQZdmJkW9Jpf 8yzl8brahrTUUbI+zTdrYzbbfLXRzni/XM+57dHNJ4K2494sNiaKQzzK4eRw5JOes/z0mLFI8jmZ6 MJsIXi335CnbVcpSZ2bYxT8Ia7qCVukJTYIKE4P0lt7GBT8/C5bG7CZCGEvhkitkePfTqB02JYiRj TXDUwXAwBLQoGN3QYIFBiVxN/pKSmq/Je0WaaxmkYGkfE5Qf8qjkgwTz2UW4V4BeOqpJYjRoNtMpZ Mt8eahnbp/U4zb6hiA4R0hn8h0rI+K1AZ4GYWKUzbvsWk0vs1uoVhwqfXm+7Os95EDR9asKO7+1yO RKLdmSsdnusDZ9dejIU6Ag==; Date: Sat, 18 May 2024 11:54:25 +0300 Message-Id: <86r0dzebzy.fsf@gnu.org> From: Eli Zaretskii To: Joost Kremers In-Reply-To: <861q6b7x33.fsf@fastmail.fm> (message from Joost Kremers on Thu, 09 May 2024 18:45:52 +0200) Subject: Re: bug#70664: 29.3; vtable-insert-object cannot insert at top of table References: <86o79rb3js.fsf@p200300d6272f17850b27304eb886326a.dip0.t-ipconnect.de> <864jbjqc0n.fsf@gnu.org> <8634r0yacn.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <6affc493-a048-465d-a237-afa03896d892@alphapapa.net> <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> <9333046c-194c-4b59-895a-2bf8427a6135@alphapapa.net> <868r0levw7.fsf@fastmail.fm> <868r0j74qi.fsf@gnu.org> <861q6b7x33.fsf@fastmail.fm> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70664-done Cc: adam@alphapapa.net, 70664-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Joost Kremers > Cc: adam@alphapapa.net, 70664@debbugs.gnu.org > Date: Thu, 09 May 2024 18:45:52 +0200 > > On Thu, May 09 2024, Eli Zaretskii wrote: > > This changes a public API, so it does need to be called out in NEWS, > > just in the section which lists Lisp-level changes. > > OK, I added an entry, now contained in the new patch. > > > A test can be interactive (since the test suite can be run > > interactively as well), but then please skip the test if it's run in > > batch mode. > > Actually, once I took out the 'y-or-n-p' calls, it turned out the test runs fine > non-interactively. I included it in the patch. > > > @code{nil}, in both cases. > [...] > > Two spaces between sentences, please. > > Done. > > Here's the new patch. Thanks, installed on the master branch, and closing the bug. From unknown Sat Aug 16 15:59:55 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 15 Jun 2024 11:24:13 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator