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

From: Roland Winkler <[email-masked]>
Date: Sun, 19 Jan 2025 21:41:35 -0600

On Mon, Jan 20 2025, Michael Heerdegen wrote:
> Roland Winkler <[email-masked]> writes:
>
>> Actually, I just read the docstring from alist-get a couple of times.
>> And the meaning of the optional arg REMOVE is not clear to me: what is
>> the "new value" of an association if the key is removed from the
>> alist?
>
> "new value" refers to the second argument of your `setf' call.  The
> association is removed if you set the associated value to the default
> value (nil most of the time) and if REMOVE had been specified.

Why is it not enough to specify the key of the association that is
supposed to be removed from an alist?  What is the purpose of making the
removal of an association also dependent on the values of DEFAULT and the
2nd arg for setf?

If there happen to be deep reasons for this, I can't help thinking that
they are not becoming clear from the documentation.

-- I thought about also adding a similar functionality to add-to-alist.
But I could not think of a way that meaningfully aligns with what is
accomplished with the other args of add-to-alist.  Removing an
association from an alist is a different story than adding / modifying
an association.  For user init files, I would suggest a different
function that will do only that and nothing else, instead of adding more
arguments to add-to-alist.