Subject: bug#75170: add-to-alist: new function

From: Roland Winkler <[email-masked]>
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.