From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#75170: add-to-alist: new function Date: Sun, 05 Jan 2025 17:21:00 +0200 Message-ID: <86wmf970df.fsf@gnu.org> References: <878qrzm4sb.fsf@gnu.org> <86cyhbq66r.fsf@gnu.org> <87zfkelf11.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28479"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 75170@debbugs.gnu.org To: Roland Winkler , Stefan Kangas , Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 05 16:22:23 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tUSSM-0007Dp-Tr for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Jan 2025 16:22:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUSS3-0002ea-AN; Sun, 05 Jan 2025 10:22:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tUSS2-0002eJ-4n for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 10:22:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUSS1-0002ji-Sx for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 10:22:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=zgB/Xiwfpyx8omjqGO1RwoSFZzfwVBf+H4z931DdQ9w=; b=FcRYZqSpQ2qgoFSmhmsWylBvtor+f71bU2g+Y4J4c8/pJuMs9U2wxhTmCrCfRCyMl1AnNCepl+0Pch27m6Zxc0lfcB1LU+y9loKV0Big74f5v/vPR4/tTfogaIvVc2lRNBpB2r4YUwHsV1x+Xr6HxbRjAhvjD40dFR317ZXbrsMAYK2VYVKNNH5pRrc8cTo1NvbAktLx4m2ra8pnYJKz2NH0T/4l76YdlFIq9PBQIrW47eL+sVWKypVOlyIVlc9K5wLKSdXntfDcOyJAy62txuWFJiJsquQn2NuEm8LFaXZ5Z2sDSqXo5qDLc3MCbyLs+ade5IJAnl1xu1ph2O2fJA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUSS1-0000zA-NQ for bug-gnu-emacs@gnu.org; Sun, 05 Jan 2025 10:22:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Jan 2025 15:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75170 X-GNU-PR-Package: emacs Original-Received: via spool by 75170-submit@debbugs.gnu.org id=B75170.17360904703725 (code B ref 75170); Sun, 05 Jan 2025 15:22:01 +0000 Original-Received: (at 75170) by debbugs.gnu.org; 5 Jan 2025 15:21:10 +0000 Original-Received: from localhost ([127.0.0.1]:34838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUSRB-0000y1-IG for submit@debbugs.gnu.org; Sun, 05 Jan 2025 10:21:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44270) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUSRA-0000xp-23 for 75170@debbugs.gnu.org; Sun, 05 Jan 2025 10:21:08 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tUSR4-0002b6-Mn; Sun, 05 Jan 2025 10:21:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=zgB/Xiwfpyx8omjqGO1RwoSFZzfwVBf+H4z931DdQ9w=; b=IPilyqQwVR7X BIZIQtEu0DBmvu5+vMhCwrfieoghQVsy+zTIX8ZL1bHhDro/EMA3m9LNjRLXBKxLED3dbuwWSmqaI tiNDm5SwnzJYwVhIVbrISeaBjtCJtjqXZEjYdituxuKUvP7n3e8dezYFtbn64CPlY1axAapUr5zaV I2kz8l1Jd7Sm9ATEBUzDJZgdiC04nVKDl6HhR6k9HZHUG9ahyl4iLExUkzbw87ImkJ0xZ4+f9ZP0L +JLgxCftgeauiNMGOWFuPp/7wQ1yD3Rvg2LGIgUrMlsZppbg8qNh634XokPsf3XZaiNwg2vzIXHgQ LFnYyrO1DKU0/LEihd8BZw==; In-Reply-To: <87zfkelf11.fsf@gnu.org> (message from Roland Winkler on Sun, 29 Dec 2024 08:50:18 -0600) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298572 Archived-At: > From: Roland Winkler > 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?