GNU bug report logs - #75170
add-to-alist: new function

Previous Next

Package: emacs;

Reported by: Roland Winkler <winkler <at> gnu.org>

Date: Sun, 29 Dec 2024 05:35:02 UTC

Severity: wishlist

Full log


Message #175 received at 75170 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Gildea <stepheng+emacs <at> gildea.com>
To: 75170 <at> debbugs.gnu.org
Subject: Re: add-to-alist: new function
Date: Tue, 21 Jan 2025 19:57:16 -0800
Looking at Stefan Monnier's set of things to modify and
remember for unloading, I made a list of things to extend
and the syntax for doing so:

list      (add-to-list OBJECT ELEMENT)
alist     (add-to-alist OBJECT (KEY . VALUE))
plist     (put OBJECT KEY VALUE)
hooks     (add-hook OBJECT FUNCTION)
function  (define-advice OBJECT ...)

Seeing these all together, I have the following observations:

Mostly these take the name of the object as a quoted symbol.
'define-advice' doesn't require the name to be quoted, and it
also has a name starting with "def", so the leading "def" is a
good clue as to whether you need to quote the object's name.

'add-to-alist' should look more like 'put' (3 args) and less
like 'add-to-list' (2 args):  (add-to-alist ALIST KEY VALUE).

We should be consistent about whether there is a "to" in the
middle of the name.  'add-to-list' and 'add-to-alist' refer to
the set we are adding to, but 'add-hook' and 'define-advice'
refer to the thing we are adding.  'put' has no noun at all;
if we add a function that supports unloading, it might be
clearer to call it 'add-to-plist'.

 < Stephen




This bug report was last modified 142 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.