all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Roland Winkler <winkler@gnu.org>,
	Stefan Kangas <stefankangas@gmail.com>,
	Andrea Corallo <acorallo@gnu.org>
Cc: 75170@debbugs.gnu.org
Subject: bug#75170: add-to-alist: new function
Date: Sun, 05 Jan 2025 17:21:00 +0200	[thread overview]
Message-ID: <86wmf970df.fsf@gnu.org> (raw)
In-Reply-To: <87zfkelf11.fsf@gnu.org> (message from Roland Winkler on Sun, 29 Dec 2024 08:50:18 -0600)

> From: Roland Winkler <winkler@gnu.org>
> Cc: 75170@debbugs.gnu.org
> Date: Sun, 29 Dec 2024 08:50:18 -0600
> 
> On Sun, Dec 29 2024, Eli Zaretskii wrote:
> > What is the advantage of adding this function, given that add-to-list
> > can be used with alists, and given that alist-get can nowadays be used
> > as a generalize variable?
> 
> The advantage I see for also having the function add-to-alist is the
> following:
> 
> add-to-list checks for the presence of an element in a list.  In the
> case of alists, this means it checks for the presence of associations.
> You cannot easily modify an existing association with add-to-list.  If
> you have an alist with association (foo . bar) and you call add-to-list
> with an element (foo . baz), add-to-list will not remove the association
> (foo . bar), but the alist will then contain both associations.
> 
> add-to-alist checks for the presence of keys and it makes sure that each
> key appears only once in an alist.  By default, it replaces the value of
> an existing key.  This makes it easy to modify an existing association.
> Only with the optional arg NO-REPLACE non-nil, it will preserve an
> existing association.
> 
> Say, I want in my .emacs file a more complicated association for a key,
> and I do not get initially what I want.  I can call add-to-alist
> multiple times, till I get what I want.
> 
> Is there a simple way to accomplish this in other ways (a way that we
> recommend for users in their init file if they do not want to use
> customize like me)?
> 
> Would it make sense to give this functions a different name if more
> often it may be used to modify existing associations in an alist instead
> of adding new ones?

Let's hear the other co-maintainers.

Stefan and Andrea, WDYT about this?  Should we add this function?





      reply	other threads:[~2025-01-05 15:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-29  5:33 bug#75170: add-to-alist: new function Roland Winkler
2024-12-29  6:34 ` Roland Winkler
2024-12-29  7:54   ` Juri Linkov
2024-12-29 14:54     ` Roland Winkler
2024-12-29  7:33 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-29  7:50 ` Eli Zaretskii
2024-12-29 14:50   ` Roland Winkler
2025-01-05 15:21     ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86wmf970df.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=75170@debbugs.gnu.org \
    --cc=acorallo@gnu.org \
    --cc=stefankangas@gmail.com \
    --cc=winkler@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.