From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.bugs Subject: bug#70664: 29.3; vtable-insert-object cannot insert at top of table Date: Thu, 2 May 2024 23:16:07 -0500 Message-ID: <9333046c-194c-4b59-895a-2bf8427a6135@alphapapa.net> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13967"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Eli Zaretskii , 70664@debbugs.gnu.org To: Joost Kremers Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 03 06:17:12 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s2kMB-0003NX-Sx for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 May 2024 06:17:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2kLj-0006Y3-NZ; Fri, 03 May 2024 00:16:43 -0400 Original-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 1s2kLg-0006Xb-6k for bug-gnu-emacs@gnu.org; Fri, 03 May 2024 00:16:40 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2kLf-0002L6-Uh for bug-gnu-emacs@gnu.org; Fri, 03 May 2024 00:16:39 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s2kM2-0003Wj-2X for bug-gnu-emacs@gnu.org; Fri, 03 May 2024 00:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Adam Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 May 2024 04:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70664 X-GNU-PR-Package: emacs Original-Received: via spool by 70664-submit@debbugs.gnu.org id=B70664.171470979713531 (code B ref 70664); Fri, 03 May 2024 04:17:02 +0000 Original-Received: (at 70664) by debbugs.gnu.org; 3 May 2024 04:16:37 +0000 Original-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 Original-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 Original-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) Original-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 Original-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 Original-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== Content-Language: en-US In-Reply-To: <86frv0frp6.fsf@p200300d6272c85ce335985c3abedb491.dip0.t-ipconnect.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284356 Archived-At: 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