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


View this message in rfc822 format

From: Roland Winkler <winkler <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 75170 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>, acorallo <at> gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#75170: add-to-alist: new function
Date: Mon, 20 Jan 2025 15:03:21 -0600
On Mon, Jan 20 2025, Stefan Kangas wrote:
> Michael Heerdegen pointed out that `map-put!` could though, given:
>
>     (setq foo '((clown . foot) (thunder . clap)))
>
> We get:
>
>     (map-put! foo 'clown 'hand)

How does map-put! test for the presence of a key (by default)?
This is not documented in the docstring.

> Which I compare to:
>
>     (add-to-alist foo '((clown . hand)))

I think this should read

      (add-to-alist 'foo '(clown . hand))

which has fewer parentheses, but foo must be quoted, like with add-to-list.

> Is that a workable alternative?  We lose the symmetry with `add-to-list`
> of course, but there are fewer parentheses and dots to get wrong, and
> all we need do is promote it.  Which may or may not be easy.




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.