Received: (at 75170) by debbugs.gnu.org; 21 Jan 2025 00:25:20 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 19:25:20 2025 Received: from localhost ([127.0.0.1]:52394 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ta251-0003nF-UF for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 19:25:20 -0500 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:46460) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1ta250-0003my-Ie for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 19:25:19 -0500 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-53f22fd6832so5285681e87.1 for <75170 <at> debbugs.gnu.org>; Mon, 20 Jan 2025 16:25:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737419112; x=1738023912; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZNK2gIxdGEpN7uuzlPBEDX3HVjjnk6U1NxGSBun6pyQ=; b=RKiFddoz4q7rUwmm/fJ+wEi48xVrk9X+8dS/su3ib1uHrgewaOrgmBj1rsRLLO9Sub pnjV+LmlA5LzSAfWIFhz8RJV9jtCFwOh672jPxFFkkSfNm79BF6fdMyROgmgaJ6HwVDa 0DQ/YKYPNEVP+F15JqXCZ2Xq7cKOYvh/IEQBha6dIcnLKU524qQ9xVgL5INURE8taJPQ p/goTvqmjwqhoeHT5WRCEPllgWJY1QnQSSTi9Rzg/mKqzF1Gd6sZ7+5zDr5ctjOnEWSg Y0T1+0mrFkYO89potqwxHpjkrDFEzNYbdL7ygS75t9wmRgkOgyMnx/O/hqj2ATMPaTKO Nr9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737419112; x=1738023912; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZNK2gIxdGEpN7uuzlPBEDX3HVjjnk6U1NxGSBun6pyQ=; b=aCoHPVDrAMYWj79Ef2zr7NpfVg+ZKgeJfQeXycF949ZCDSRzhYKQZW3YoVxPl+W9EO 5rXRPvDGw+ImnNJIfCb5LT6uSHYXYyJII6xB17AQypMEQDIN4R1gS5GjGhFdsbAE9t8d YY9aw+LW0L6bo6DH6YRkDcWx/S1yPREzUhpQn9bZOG9I5R3PyoJbDE/gs8JRXS304z42 q16DUDMs6v+P3BMcYmM79zW9kq3bojVFGIduxFWLEGy4MOucy1hPGvQtr0A2MOSKEeM2 qe6Jb8TgxL2Gxgfu8U2kco/3UyhF8Tgoa5ahyqkraJM1B7VZ5EHyv2S2eRfAaBAnWRTD VQeg== X-Forwarded-Encrypted: i=1; AJvYcCUW2pnkaoaLjUsfElMWX1sFwCFkxkxp/+CYJTb50DCzSs3KOuflDU+0qTbugBvGKbwHbRejiA==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yz/GqYtH++AkWWd8nNFgoyVFaQkNWyCAWdPfbHpDu9ScZyOx07d P+wLdswfNRplCfTq7sNs5xgJkAFGL1ql9+Dzzj+OxphY0Wl41UCvv5u51yae8XAi1khzs1T1fqv 7AeEnH8GepRmZN4PZHEyUCp9DXgrsxEbihvI= X-Gm-Gg: ASbGncvloGo6oNCcAvld47uTyhv1szOPxdDjqD9TKfuueEey09sPZ0wgWVLy+peLMBr WOJccpsa8HXYTK3I9nb049PRcPWrI/5HS2oiYOeQlebT9CwSckq13/A== X-Google-Smtp-Source: AGHT+IHEj4yfz4bKp4w8hSpmy7ZGL/LGuAYpNykcNPwubM90GP6paYEKcDdjd3mIdQXens1iqZuWdqEhi+99h5lOawQ= X-Received: by 2002:a05:6402:2696:b0:5d0:bcdd:ffa7 with SMTP id 4fb4d7f45d1cf-5db7d2e2e0amr12684174a12.3.1737409248608; Mon, 20 Jan 2025 13:40:48 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 20 Jan 2025 15:40:48 -0600 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <87wmepryee.fsf@HIDDEN> References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <86sepgbh5j.fsf@HIDDEN> <87ed0xd8t5.fsf@HIDDEN> <87a5blti3v.fsf@HIDDEN> <CADwFkmmVjE3Sw6J4mHZY1UhSrJ3FRqVQ0rp-11E6gC8R58F5ZA@HIDDEN> <87wmepryee.fsf@HIDDEN> MIME-Version: 1.0 Date: Mon, 20 Jan 2025 15:40:48 -0600 X-Gm-Features: AbW1kvaw2xx7PKPO5a2xQAHohLxiWci1qer0EuOPU0h0QBjyGf5Ocdsy9GwEDuQ Message-ID: <CADwFkmmdWjpnm5Q=phJNLJUd127_keEUC+SsLTPZjBu=Rw1wwQ@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function To: Roland Winkler <winkler@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Robert Pluim <rpluim@HIDDEN>, acorallo@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Roland Winkler <winkler@HIDDEN> writes: > 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. It's not documented, but my testing shows that after the above recipe, foo has this value: ((clown . hand) (thunder . clap)) >> 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. You're right, thanks for correcting that. So less ugly than what I wrote, and close to what an alist looks like anyways. I'm curious to hear more opinions about `map-put!`. I'm also copying in Stefan Monnier, who added that function (or at least named it). >> 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.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 21 Jan 2025 00:15:47 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 19:15:47 2025 Received: from localhost ([127.0.0.1]:52347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ta1vn-0003IM-68 for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 19:15:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49836) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1ta1vk-0003I7-JS for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 19:15:45 -0500 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 <winkler@HIDDEN>) id 1tZxCV-0003MU-Rq; Mon, 20 Jan 2025 14:12:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=9an+xXN0bn5sOQB6DHdo7WSHvq5nlWYB7PUR0tY/4ZE=; b=fKjSoNwL6DcDu+20AwdB 6iIPri8UM25p6M5ZfaLBW6nsRd/RFaII/jsIar0SjxPS73ZWs/u9TbykOj4cukQxE3yqYKOpLQq9k 5KggU5Ym5YePfhe+hrsh2GuySOETXlJGpLQ/ZLc6Qzv66+OZNcywVt6SRKPBIFXydR91lL4ZAcNeS lFOtEOxDVHObIz4hyDcKiTttad2Pz7jXM7f5pJJTrb9sqFb85ipqt99fOtddpEPfnstmAdPam1YAO lZLptVGQm9tDK7R/C993vAuUvnmU7nTSMDBy2VTmATd4BdX0DVA9nBcJVU/frhoOxaLlr2Hlhb3fC J97MumSPIOALdA==; From: Roland Winkler <winkler@HIDDEN> To: Robert Pluim <rpluim@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87ed0xd8t5.fsf@HIDDEN> (Robert Pluim's message of "Mon, 20 Jan 2025 12:27:34 +0100") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <86sepgbh5j.fsf@HIDDEN> <87ed0xd8t5.fsf@HIDDEN> Date: Mon, 20 Jan 2025 13:12:20 -0600 Message-ID: <87a5blti3v.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>, acorallo@HIDDEN, stefankangas@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Mon, Jan 20 2025, Robert Pluim wrote: > I=CA=BCm not sure what this would offer over > > (setf (alist-get key alist) value) > > which will add a key->value mapping if it doesn=CA=BCt exist, and replace > it if it does. I also don=CA=BCt see a real use for retaining the existing > mapping: `alist-get' will return the first one anyway. By now, this approach has been proposed in this thread a few times. The question is: this uses the concept of generalized variables. Is this a concept we recommend to users for their init files? To the best of my knowledge, previously this has not been the case. I am tempted to argue that in our recommendations what users should do in their init files, we should stick to strategies that are as simple and transparent as possible, and the above does not match that criterion. A collection of functions we recommend to users for their init files might be a good thing. add-to-list already serves that specific purpose, and add-to-alist could be another one. Roland
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 21 Jan 2025 00:06:22 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 19:06:22 2025 Received: from localhost ([127.0.0.1]:52311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ta1mf-0002o8-P3 for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 19:06:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50358) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1ta1md-0002nr-Ou for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 19:06:20 -0500 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 <winkler@HIDDEN>) id 1tZyvb-0003CZ-Qt; Mon, 20 Jan 2025 16:03:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=36tjylH/lWsl6NGPEbHKjEnHAI4XUeVXhGtmS2Qi3FQ=; b=IFZh4BwKE0vFPhed+TI3 Pp4qEiYkZKzAv0gfutM2qHbILWTqqeqXFcn1Dd11hKJGynYq69p8vF3wlDwCXRcvUTcA0RApfTXX0 V+EWwerMJdrzsjecaMuZwSrmE585Ktbfo3kugQJGJFj5uou6REm2jdb1ooOpQkcsXVEJadRei8h9X mg2H44GhkhDeS0qmEFVCUcv/auzujyEinB7gtsm3qMLXd1h0KRSidaqNEUr1Ep8ru8ApdRYasBzKG oYTd+K0G03lTqoYkdCUW18bIOtM1zFQfyd3ykTUTEJ16V+2uPJDw7P9I+zN5j0xiCx6JxS68OpiTt addTLl4OyrU6ag==; From: Roland Winkler <winkler@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <CADwFkmmVjE3Sw6J4mHZY1UhSrJ3FRqVQ0rp-11E6gC8R58F5ZA@HIDDEN> (Stefan Kangas's message of "Mon, 20 Jan 2025 14:41:28 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <86sepgbh5j.fsf@HIDDEN> <87ed0xd8t5.fsf@HIDDEN> <87a5blti3v.fsf@HIDDEN> <CADwFkmmVjE3Sw6J4mHZY1UhSrJ3FRqVQ0rp-11E6gC8R58F5ZA@HIDDEN> Date: Mon, 20 Jan 2025 15:03:21 -0600 Message-ID: <87wmepryee.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Robert Pluim <rpluim@HIDDEN>, acorallo@HIDDEN, Eli Zaretskii <eliz@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) 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.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 23:44:31 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 18:44:31 2025 Received: from localhost ([127.0.0.1]:52225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ta1RX-0001f1-69 for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 18:44:31 -0500 Received: from mout.web.de ([212.227.15.14]:57567) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1ta1RT-0001ek-Ta for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 18:44:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1737416656; x=1738021456; i=michael_heerdegen@HIDDEN; bh=CyW0e5LO7vzm0KhuI6fYHGDRfFHiduGD8qPM0yP7BZE=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=CWqmvnujTiraXhSULvdUniNy35qwK1FWs+e8YfudRp9q7nzSTUCzx288lBUBzk/V 59AfysQ2JECGO7W5CeEptD4kj0hyj7Imz15yxGKVeXJZdTarCy4uTec8MVkrhPvF+ mpMrSoIMhlC3Rutx/0iQ1HjNjBSGKL3cA/+blbGku0H8E8YX3aPJsX8yldutXbJm9 D4RmzAk8mggL3Eec5pgWcNDC+18cLSfHGWqfxxq+8romyVsvHE5x+q4HWXI4Vm1cH Bl/3GcFbBYYcrnLXlfbiQ1xrpuKMIR2o/lyBCy2rAyUoqnDuHK/aOPdBAx56Jqoq9 GSpYXA/osIEDrHdtqw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N3Xjb-1tQnYL2n4t-017NeR; Mon, 20 Jan 2025 21:52:06 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87bjw1ti9k.fsf@HIDDEN> (Roland Winkler's message of "Mon, 20 Jan 2025 13:08:55 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> <87ikqaguor.fsf@HIDDEN> <87sepetamo.fsf@HIDDEN> <871pwxha95.fsf@HIDDEN> <87bjw1ti9k.fsf@HIDDEN> Date: Mon, 20 Jan 2025 21:53:21 +0100 Message-ID: <87sepdfbr2.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:hd/y/j9sNZUSd04apjhSR41do/HrFEauzp0VzlZlMORjWFB7wsv a5O7oRM5lGkixZIBPC2fgGSoYYf9ME5v8oAJR0QfldweQ/jaoRyHAUo4oZDL/6olqtLXlYY D9FV+EzprqMl63RzrUI7+LSGtYuXVdYPG5xqDtW1r2+zAJ7HXbR9RBtm+QgxneXtfK6tf5R 6h/QnR5E2dwRWNLzgE1eQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:4vA6rjtvifE=;NqvI2Tq78RF/8kw8JTxTGg+6QDZ cpvFNfwsl6QugVG+T/PspOJ2EJDpMEW7Z17R1oRN1sxYM4WZ8OzkRPq6DjkriA5qDMji8tMuH nHA1HQTdIJx0KbEZKFaJhkWWJTcRcW4S4EXFPZyrmAJF/LAkjabGtZxrAG9SdKo3ihHSIjet7 h+ftwDBYoHmp/5+CZo+RLaSbYDaWlI1ltuENEXyG9UQi39S59ssAAlNxAUiu8udtjD8UUDFtj D18N8aDLPcpzrcc6Onpb6ZrqGnYfDuPSKZuI+akjDwNUHUlimdufPhWrTFk6Bqik/vwn2ogU+ atAeKUH26810OjoLu/caeZOaGcYkVhXX9Pyye3kG6bAk5csXLdcG2XayhpG36D+WUXVlysLxg Oud9SCLME0eum35LkOe/g2Kt8/ZXQq8nZ4D7ROYMLQx21kWbv0ao8t3CzO0U7Q/BOxjaftL9r gxxDdjV93O9xqBEcPshobzUTOYyUIoJPjEZMT9w9T8T8tA0PvziDrRJ1BCyMTQyVJIje1WQIs UTta+iN7IvxHumIuwBSOKLQSAuvObO0A7Fqp93gtFnOKQEXeFE8AiJ99d874GRkSSLNoDGNnC R3J2qKxKdCfTecTY2yfmJG4lE/xjkci/srj76QbkZMSscPJ8eIlVgzil2lFoY5jKKoGPlv9UU lVHozbZfMnUXEFTFLVK7X1FzSx5YbitBX64eKCjdk23Dbc+Yu2HVvNOiablj5wby6c2aMNPTp WX55V8ES5sg0nK/NEBmsI52WoumQtvIyKui+1U8Mqvh2hVAnMlsvkT7oHrKxy/ynchczt29LX ewKXnxQyJx4kAfUJVecTp575n1FAE+h4yMEBIc0xhV4FHVc+JfjwfrP24/BEueGKgrUXYgMqG xSD/ayXAGS96lemOr8yIurYaiI5LAMcgBYFA7rLAm2sszWERFDNFwimbbBM3NsynquQXXZm5R KS6NqyrEWgu7y2YDjf4Et+dfbX4F5VYknvCsnabOUMhP4HFdeFAOoZvGou08RbcaRbcEhsF8Z qui+BwPVuLnX9pJ6c9StvXe4IfBbJ/RQAl3qKQw9pC2Z32XPME/NNuAVyS75FYsOUypdpNsay oyUHq+nmERyt9/WjXOBBsRmNH9QYPer1fL045922Kb31GSjXbIN0Akd8xxOIEHsANBtzzHnoL X6S0gDggKD5eSJ2Tp9h9W7Gmxl6Pssp3XyWoyJ/J/KQ== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Roland Winkler <winkler@HIDDEN> writes: > Sure. - I just do not know real-world examples where this combination of > things is an efficient way to go. I don't know what you mean by "efficient", but the Emacs code base has examples of uses. You might want to have a look at them. Michael.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 23:28:03 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 18:28:02 2025 Received: from localhost ([127.0.0.1]:52043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ta1BZ-0000ii-TC for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 18:28:02 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:49358) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1ta1BP-0000hz-Ov for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 18:27:52 -0500 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5d982de9547so9809401a12.2 for <75170 <at> debbugs.gnu.org>; Mon, 20 Jan 2025 15:27:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737415665; x=1738020465; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=v+tLl3M2RhVGhLfMBszlWaU0z+aFj9KJKnkfO4X6aMk=; b=hRySmRER594JoeKwIkPcXRj0gJha7AU+JxMHCbd2G0bMaVCiWyvj1uqJXESwwWuYTZ Saky8+wS2O3biHAvTINrgruaCVXPKQ9xmDOnmUc80N3cWjooMSPVXpVgi+57I+Hqn7rN 6bIoCBJM7zq3FKWREYTSl/3vR+RSCI2sEoy3FQHOIZQuU9ngVhw9T17jrC8Uo7wYJbS2 hqzpvIg6nL2NSGboyLzIHPg4urxtBgm7K/sCDTG8fsTC8oE/qdCoCu3rQGfY7eNZjTY2 b4CURPd0yjIdmYIbKt0zA6WntbHgO7JUQiu7a5tbno6fzY7C4Pooiy1P6OcFg6pVgJHW ++Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737415665; x=1738020465; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=v+tLl3M2RhVGhLfMBszlWaU0z+aFj9KJKnkfO4X6aMk=; b=EQUbLl0aW0dZiSKXQXpuv5VLgDSvWRm8xZbwzMu8QRsUwbEg21ot0DwEkXYnrrzQJ/ ERwxaysFgAjcF1YnnRld0ECn0J0lbLsIV8UpqZEv/TCPoHJrawDp5LV8H+bc9UeyKDBi Qe9a0TfN+ytxZqvzs8KDi0TNdkbRGyBeki1TGs5hJOJaDkeoRGZK1AcBGzTmIHF2Cia1 WuuyN3UHDx7XRc49MImhuoi1NcXRCZaAAzuPLPtqqBhvc27TIb6J3B9DrRiLeqda/snO mL5chXvIXBU+ouYo0OIlxCg+AtMohlxHWQcsyDfkTtWNwuNfnIwzVfrQVGDh3Md31hL7 vp7w== X-Forwarded-Encrypted: i=1; AJvYcCWchb2rHnpfWr0WLY2uRs1KXRAmxiaC++4oNOl7cNfbb8q/fqKz0DidwUoko0xaWTYhoTEV7A==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxrVXwPE+2L7JOMSgZ2s0aASQ5aTB6Js5mYhejCvnmELCULc4BA 46+UO+SmF09mBRc+DjdQ7MkRk/yrfH1wPR4g+mZjraJ/nqp3SJapyg5wN26QAqbe7ZrywuGDM6Y 333MgGhuc9ud72m7znYmYrXgQ3rTmH+wSHaM= X-Gm-Gg: ASbGnctGLyF6X7p+qudaoKPems7I0KpVpIYkO/cfrWYQHcWJ9dQTGnjS2jrFvGO1Prs YdEL49UpcQsFIm9J4OeCVeqxvebML6nKJ8Tzt+9hKeA8zLNVHp24= X-Google-Smtp-Source: AGHT+IGhhLdyNih3atGUVr/X/PJANFjA8wtKnG16g8P3Wq+/fsIcXIXBqMAWVdtXuFqA+Llv4wJnOTNQz3475hWznPs= X-Received: by 2002:a05:6402:3496:b0:5cf:bb9e:cca7 with SMTP id 4fb4d7f45d1cf-5db7db29e89mr13710179a12.28.1737405689200; Mon, 20 Jan 2025 12:41:29 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 20 Jan 2025 14:41:28 -0600 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <87a5blti3v.fsf@HIDDEN> References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <86sepgbh5j.fsf@HIDDEN> <87ed0xd8t5.fsf@HIDDEN> <87a5blti3v.fsf@HIDDEN> MIME-Version: 1.0 Date: Mon, 20 Jan 2025 14:41:28 -0600 X-Gm-Features: AbW1kvZlnchCGr3Z4rqsfPQ8IK3AAuW2MvaAk6q_N966isueGWBCDfqn-3fZGNM Message-ID: <CADwFkmmVjE3Sw6J4mHZY1UhSrJ3FRqVQ0rp-11E6gC8R58F5ZA@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function To: Roland Winkler <winkler@HIDDEN>, Robert Pluim <rpluim@HIDDEN> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>, acorallo@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Roland Winkler <winkler@HIDDEN> writes: > On Mon, Jan 20 2025, Robert Pluim wrote: >> I=CA=BCm not sure what this would offer over >> >> (setf (alist-get key alist) value) >> >> which will add a key->value mapping if it doesn=CA=BCt exist, and replac= e >> it if it does. I also don=CA=BCt see a real use for retaining the existi= ng >> mapping: `alist-get' will return the first one anyway. > > By now, this approach has been proposed in this thread a few times. > The question is: this uses the concept of generalized variables. > Is this a concept we recommend to users for their init files? > To the best of my knowledge, previously this has not been the case. > I am tempted to argue that in our recommendations what users should > do in their init files, we should stick to strategies that are as > simple and transparent as possible, and the above does not match > that criterion. A collection of functions we recommend to users for > their init files might be a good thing. add-to-list already serves > that specific purpose, and add-to-alist could be another one. I certainly appreciate the arguments against adding more redundancy to ELisp, but I think the point still stands that Emacs should be easy to customize. Generalized variables don't do that job in my book. Michael Heerdegen pointed out that `map-put!` could though, given: (setq foo '((clown . foot) (thunder . clap))) We get: (map-put! foo 'clown 'hand) Which I compare to: (add-to-alist foo '((clown . hand))) 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.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 19:09:07 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 14:09:07 2025 Received: from localhost ([127.0.0.1]:52341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZx91-00030u-45 for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 14:09:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40204) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tZx8w-00030C-Sz for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 14:09:03 -0500 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 <winkler@HIDDEN>) id 1tZx8r-0002rG-FI; Mon, 20 Jan 2025 14:08:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=x5Fhl+jqRXdDFagsksJ0C+5UIgbP0sdKMeD9wbBZYKw=; b=PZOzmNvAUAhAqhDQfpH/ PgTtv46XiYjqs/lXlPdvHMQCsA2scfVuRuwULTNJLgowdkTAmAfRx5sVGmJZ5mfxVsXL3j6uz55He BZjMqKR2ef31RFtv6AfqRbFdHk/TCg+dB6G/dIjTVhBSsONmloXYIz9MS5ECVOOFPhCzSvUBShgRk DrT543tylRJznnH/gkjiZ3tul6olqQjae6UNFSyfkatVnUF90vQd4WSqPayLL7J6yrs640BsGmH7K O94SGeWWO6NgqIm9AIWdKzsr08Uqi11gXmL0Gd1Kb8zk2JxIhpqngsnvuYO52M5bWb8ecZqkLvYCm c7X+Yd9z7pDDxA==; From: Roland Winkler <winkler@HIDDEN> To: Michael Heerdegen <michael_heerdegen@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <871pwxha95.fsf@HIDDEN> (Michael Heerdegen's message of "Mon, 20 Jan 2025 14:42:46 +0100") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> <87ikqaguor.fsf@HIDDEN> <87sepetamo.fsf@HIDDEN> <871pwxha95.fsf@HIDDEN> Date: Mon, 20 Jan 2025 13:08:55 -0600 Message-ID: <87bjw1ti9k.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Mon, Jan 20 2025, Michael Heerdegen wrote: > Please do not limit your considerations to this special case. DEFAULT > and the second arg of setf are different things. The expression you > setf to is not necessarily a constant: > > (setf (alist-get ...) (get-the-element)). > > > About your second question: Please also think about the general case. > > The promise of (setf PLACE VAL) is that VAL will be stored in PLACE > after the operation. The REMOVE arg just means: it is allowed to > achieve that by removing an association when appropriate. > > (alist-get ... DEFAULT ...) will return DEFAULT > when an element is not present. If we setf to a different value we > can't remove anything from the alist because our promise would not hold > and it would not be appropriate. Sure. - I just do not know real-world examples where this combination of things is an efficient way to go.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 13:41:43 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 08:41:43 2025 Received: from localhost ([127.0.0.1]:49409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZs2A-0004Xl-OP for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 08:41:43 -0500 Received: from mout.web.de ([212.227.15.14]:60001) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1tZs27-0004XV-TQ for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 08:41:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1737380488; x=1737985288; i=michael_heerdegen@HIDDEN; bh=JCAwx8Pw7A5MaY2cQmhpXSbhGJsUIVfSQdXoB5o9OC0=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=a9gjJtQg4aGGsJtfHaTcl80jdv3/p4gcDwxOsCmDJTWXPD8ZKNqnPAiyn5wLw9qs m23eFqMOVPAJ+ZOrPNKZNPnAQE2i98I774OU1wYKZsoun6rmcfP0C1KxDrBsH9JBx I1UNCOvLIRgkm+fHNhfgty+2SZGMKbmDsP6XsdfG70X6zGVvRZeelt+BicpwUiPhq yBFAHmswnLyd/ryZpd9sohyK1bPVh1rAdsiiFqmBQYvd6Bona8A+x3PFoVrYta2D5 ihpCA2P1zEcR/NI8hB9VeLRqD2n3LVe91dVn81WBLcpfkVoMRnv16PV2mFsGqxRxw nQzlx4IlNRjWMlawzA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1Mtguh-1tEmF53HAt-00vIoL; Mon, 20 Jan 2025 14:41:28 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87sepetamo.fsf@HIDDEN> (Roland Winkler's message of "Sun, 19 Jan 2025 21:41:35 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> <87ikqaguor.fsf@HIDDEN> <87sepetamo.fsf@HIDDEN> Date: Mon, 20 Jan 2025 14:42:46 +0100 Message-ID: <871pwxha95.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:E0zUyZC6rzAMBKY5DnypG5HU+YLlQuKnsgqINYXkLbAp1I8vu03 Zlgfq6gXNFFgdpKm4S4pnTaTUimSGFDewD7VM4QdyKQh5SgNF89Rm34mC4RXZErWTcz5h/V Z44GRD5UfI3lNGUelqqd2B1LljWJHKC1Po3l3OHFZVN9+DFG4YHaDlgAY4H5bHarQnBtB9B MnhcdHWoW6zHcFAvgm3OQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:vNXAKaIHjIE=;GV6UJvhEql3txETp9ENQCgYrJxZ vQ3uopvg+i5deID917yULcC0BIV+1KNUa7wS2Fe6bsKCz1ONAsE+IBsJ8qU58YPfz6vrUZGR3 M1cTH43A69TCZLKflY+B+qXRfzsqw1C6gRBpA33vZ5Ux9ymb8QvN8EUR4LWNsMwVuIh5J+JIE VCTaw+hhIILbWZF7jJdPqwqI3rLIx67sO9Jdfs/EmdDC5aMtLdlKwcDkGZvmf3M0CU+KHtfgX EJa8owoUAf2w76e3v5VKOhjY7I59AF1Hsja8ZxHBQ3KTK/9wg0v62z+RVoITexHW/hIBhMKfJ /u2ZoJEA6ZzomSKH/M0jNP8K7msjAgvvstdPHwmRnLUa52NQe7QTWyyazflS/WR7svigRgaQh 0MPGwbwwu7nrcoxNBRpmmRKPWd1TlilKFsYyQHAIUyiXEFohUS1Xrjg7eAK7IRJLiKOABVdhP udFMNm6Llud55HtHh71uG7hDiYJuMG8+c5Bjz6e1/uevNPZQI9m66qzaq5KG4htq37W2i6GEQ aPnWwKLb9sOTCcDDNO2iPB9MO6kZzqyyVS0UZe2ecXqvnUlflhLYqSAiX88hF82WdY3oSmgow dHingpA4y1VzO6SQpcCzwhX5e74lobs7rml3XbaduBLHFKJ4FEp/VlFGPSg4ReOZLknT95N1H HBoCJqk5pjzMdQmmxZaqXYIUyVj/oX4D5ps5hMjgw7uhY1G8J7afblIN6KVSf4RKGAlQoCcZd LyXPRpZIVR9ofuTbAixmyqZecGwHTBEQpf0y3HJG4xD4SKd8YAADZaocElNTP7H7STkxmaLMu rMQqtuAe6CJYtyJdiiJPTN6Cmc94KrncxTDl5ePkctREOx20jz9PJPtTpGiTxWqC7uuX3JGig Plfy8+k6re9C97faNDCkC6wrQbHzuLfy96rQv5p9KLv4nn7zszIqzdc+vDbC5IEbexU+4q5pS f21Nv4QZZCzyt2IyHhLcmxVn/rdO3MjlcyQCWF1eylICpF5ghasvYWPxEcqtX6/JqUXywSfvZ tSoc9zK5nO3eOBODhezxm+7rP8PbkudrPLV8tXQ9vBEMOVbuEhJsKDJHcMPmNDPOlpnHdVUpD syV8rGEI6LI87wtS1OgcxLVTL7nBA3kvucDd1RpWnIEtrXvOcr+kEZNa6jXxPq4D9RkFOMUiQ BXPim32D1IpW7YBPDvXhOht5WcYqTOVoTeUJcXLaFiw== X-Spam-Score: -1.7 (-) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.7 (--) Roland Winkler <winkler@HIDDEN> writes: > 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? Please do not limit your considerations to this special case. DEFAULT and the second arg of setf are different things. The expression you setf to is not necessarily a constant: (setf (alist-get ...) (get-the-element)). About your second question: Please also think about the general case. The promise of (setf PLACE VAL) is that VAL will be stored in PLACE after the operation. The REMOVE arg just means: it is allowed to achieve that by removing an association when appropriate. (alist-get ... DEFAULT ...) will return DEFAULT when an element is not present. If we setf to a different value we can't remove anything from the alist because our promise would not hold and it would not be appropriate. Michael.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 11:27:45 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 06:27:45 2025 Received: from localhost ([127.0.0.1]:49177 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZpwW-0003MB-Q8 for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 06:27:45 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:52629) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <rpluim@HIDDEN>) id 1tZpwT-0003Lp-UW for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 06:27:42 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-436341f575fso47263075e9.1 for <75170 <at> debbugs.gnu.org>; Mon, 20 Jan 2025 03:27:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737372455; x=1737977255; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=BmHxnmneg5utM6GuBZ3KOB3RSq9Y8QWuIUOzXbzibZU=; b=H3CQcfyCN3JJrx/QQ2iVXYcm5eIP01l1iNyE/Aq/cNtOG2arP+lUv2V3alFfY5pUBG GDRLcGsCpAD1tEjSBcJyKzzQlFSmqijQyWSKWR4mVwgecrL1K54jjYY2+9KmxXu/wMcH LkcCaEPApmjqGuioGlM0QEV/E9tjP7t3iP2nF4A9BVlA7abarP9ghcJQKc0rnojaUWLs 0C6ccLBZOU/9943Ks+Pe+H+HqIrzM2nWlQIv/SPHkId48ZmnpxH6uqWAQQbZeIOo9F7F SBAzgXbIvZL4RZubVyw4tOeusk4KETqycWyUN0UWn6fsCKotQTsI6pMzw5qk9TlS9d9t xbew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737372455; x=1737977255; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BmHxnmneg5utM6GuBZ3KOB3RSq9Y8QWuIUOzXbzibZU=; b=U0FZiJDTuDwn2cfuontqEaDcZX1FxcOlH5a5vw3G9jSZ1aUUVgkmAtTFEDFnPWnysP R8EMkhgRLK/Tuml3PxV+xE54jMj6zajEPmr0RxfdacpHe2YbkZUS7LO7BYkIKl0E7QOz kIZHofVydjYUt96pkl+ZlwGQrMGuELW2RQGtVp6OH16tC10c+1ASaYY/jOd7qWLpDuWY 2lfbs0H/u2LCj2VzxRriZ9HpT3tLtrOfHk2iG85YfqWMEtlm5Ws5Z+vKuUyvS0bFyEFg gTcBSaG7lgflK9xAvCe0PF55d5R54xGs2VwCHKvkIJ5ydioga1w2Le9XmShxSiIBNFZ9 6WQg== X-Forwarded-Encrypted: i=1; AJvYcCWeji1OAFp9vbuJPl0WR9DsvxwcHWIucrt/U3kEVr4teG9qlzUn+XHLL+V4MOFRJshR3lCSKQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yy4YVnM5DiPxulCQyCvrtxuTRyQZ1Mf6GINVK/QmJkMnOyvOk4M JxZ4ttFrWwWHOq55Cee+8gdu+sP47mkaroI9M9alaqQ8s/tEbs5M X-Gm-Gg: ASbGncvEsgRLzPENHrC385Ow4MHjjPAyOCbyAw4w7tGAvJf+JjeOtX4UbmpKc2N+AON SR+DDCsi5hIfey3vDDjwJBCcxlrrBBpZHeo327fa3UybwjUkpe1PtLY1CjTQCEsUTThH3xOfkoX iuI44f74a7u9jD0cDXh+ELwx2UptTIU0ryC/QleSKtGGfCGzC1GBXzSX7IiltLD8hVH1WSSN4z+ eyarSzgkdlPGpbMQ+eCGTNa6gEVBs1brQYycLQJrS8tImrRQTc2bS6wTQ== X-Google-Smtp-Source: AGHT+IFm5mts5clAN8N+kvnPwleimZSTn144C/2UO35//YhBuhYq1qnDGj6TPH3bkdIO2qtA9w9H1w== X-Received: by 2002:a05:600c:5253:b0:436:916b:aaf4 with SMTP id 5b1f17b1804b1-438913deb86mr134835615e9.10.1737372455134; Mon, 20 Jan 2025 03:27:35 -0800 (PST) Received: from rltb ([2a01:e0a:3f3:fb51:2aee:9648:dbc3:ae30]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438904087cbsm138491645e9.3.2025.01.20.03.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 03:27:34 -0800 (PST) From: Robert Pluim <rpluim@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <86sepgbh5j.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 18 Jan 2025 11:33:28 +0200") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <86sepgbh5j.fsf@HIDDEN> Date: Mon, 20 Jan 2025 12:27:34 +0100 Message-ID: <87ed0xd8t5.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, acorallo@HIDDEN, stefankangas@HIDDEN, winkler@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) >>>>> On Sat, 18 Jan 2025 11:33:28 +0200, Eli Zaretskii <eliz@HIDDEN> said: Eli> Ping! >> Cc: 75170 <at> debbugs.gnu.org >> Date: Sun, 05 Jan 2025 17:21:00 +0200 >> From: Eli Zaretskii <eliz@HIDDEN> >>=20 >> > From: Roland Winkler <winkler@HIDDEN> >> > Cc: 75170 <at> debbugs.gnu.org >> > Date: Sun, 29 Dec 2024 08:50:18 -0600 >> >=20 >> > 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 b= e used >> > > as a generalize variable? >> >=20 >> > The advantage I see for also having the function add-to-alist is t= he >> > following: >> >=20 >> > add-to-list checks for the presence of an element in a list. In t= he >> > case of alists, this means it checks for the presence of associati= ons. >> > 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 assoc= iation >> > (foo . bar), but the alist will then contain both associations. >> >=20 >> > add-to-alist checks for the presence of keys and it makes sure tha= t each >> > key appears only once in an alist. By default, it replaces the va= lue of >> > an existing key. This makes it easy to modify an existing associa= tion. >> > Only with the optional arg NO-REPLACE non-nil, it will preserve an >> > existing association. >> >=20 >> > 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. >> >=20 >> > 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)? >> >=20 >> > 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 i= nstead >> > of adding new ones? >>=20 >> Let's hear the other co-maintainers. >>=20 >> Stefan and Andrea, WDYT about this? Should we add this function? I=CA=BCm not sure what this would offer over (setf (alist-get key alist) value) which will add a key->value mapping if it doesn=CA=BCt exist, and replace it if it does. I also don=CA=BCt see a real use for retaining the existing mapping: `alist-get' will return the first one anyway. Robert --=20
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 09:59:54 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 04:59:54 2025 Received: from localhost ([127.0.0.1]:49025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZoZV-0007Cr-Pk for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 04:59:54 -0500 Received: from mout01.posteo.de ([185.67.36.65]:44015) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <thievol@HIDDEN>) id 1tZoZF-0007C8-IN for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 04:59:37 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id EC801240027 for <75170 <at> debbugs.gnu.org>; Mon, 20 Jan 2025 10:59:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1737367170; bh=loWiO9Uo5oH1yq7eLfwteFEIHXy6FO5G+t+TQH64XKc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=AivJW+vQKvmqQ1z/L6uz9a21jCuxlT01nSHVHoaLoylcX7zBh0L49bsCYw2trGF6N FQtTJEqnWF3WVRTcVsJcjrRkdvJmgScAg45i7jN2G8Z3R6YpawIz1zqqeT5mwZ6VuH TEaI5r5Abf5YJEiF9NY/ju88BLLr9whcYdIt/zEZ9fe8Cc4mEBWePGKoqFtum7FwiZ 7XE0IA7rnKb5sneKWv9oLgVjsIZHIdMoYpTqe31+GCuHAjeatoFKTdSOxqM8dtX2dH aqlOnRDoAB2MNZlJ5yaS038geqc1BV7yxPFr4f6L4XqgOYmnHXT2YFcAXHdyEX5LIT VT3FZf5t2R1gw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Yc5R46JLHz6twH; Mon, 20 Jan 2025 10:59:28 +0100 (CET) From: Thierry Volpiatto <thievol@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87zfjmts7x.fsf@HIDDEN> (Roland Winkler's message of "Sun, 19 Jan 2025 15:21:38 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> <87ed0ydef1.fsf@HIDDEN> <87zfjmts7x.fsf@HIDDEN> Date: Mon, 20 Jan 2025 10:06:00 +0000 Message-ID: <871pwxvlyv.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: 75170 Cc: Thierry Volpiatto <thievol@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.3 (----) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Roland Winkler <winkler@HIDDEN> writes: > On Sun, Jan 19 2025, Thierry Volpiatto wrote: >> While you are at it why not implementing a add-to-(a)list function that >> add/remove an elemnt at INDEX in list? >> It is what I am providing for my users in Helm. >> >> (setq example '((a . 1) (b . 6) (c . 3) (d . 4))) >> >> (helm-add-to-list 'example '(b . 2) 1 'replace) >> >> =3D>((a . 1) (b . 2) (c . 3) (d . 4)) > > I am just curious: when can this be useful? Also the usage of an index allows things like this (what you asked in first place): (setq A '((foo . bar) (bar . test) (baz . else))) (helm-add-to-list 'A '(foo . baz) (cl-position (assoc 'bar A) A) t) =3D>((foo . bar) (foo . baz) (baz . else)) =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmeOIAgTHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvkzIjC/9+fQT/0LPBL2zg1Be3K3Vs4AkGfbuC 659hhq2zg24Se3oL0HqshHFJxZu0C1Ut/iUy77Gfgop0jSZPn45Bt449uX20uajL qgH6NkOpyKwOvWuvM8i8qG9Wh6qbDqWvHKmljsrPLngvNL9UIB6XwRHXrnzsJTWt cRXJ3h0C8ffCbQIshRU/VIvUHHSR1MB5RXNUNhKigRjjfet8Y++weg+OWxSPPEsF sM81+nc+AYg1SQBU/XfXP3w8SKR+tu70FjUMgGR7AzLrH6kISR6Ydg+AcHK6DmJM peH1L3C9Uh+oIIS0AjLK/nSodtyUAprksMLkpgsuAVLAUatLN1ivPtpACdUH9yyT yWgAtE0QdKiFwdQJtJ1shzizqxmWVg2aMe4hFe8Ngv6RQh0rOW2tlV9zFnpVq85a AlC8BPb4gfZMQ6GoDGSf5a/WKDyIJ+W3MPmB1XeDgtqvTgWSXxvy5mK9vqA3S9DF upp36CaN4HDvSLksTCXLA+Znk9fgS7KZ1P8= =J/QD -----END PGP SIGNATURE----- --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 07:26:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 02:26:00 2025 Received: from localhost ([127.0.0.1]:48808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZmAZ-0008Oj-Gx for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 02:26:00 -0500 Received: from mout02.posteo.de ([185.67.36.66]:36449) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <thievol@HIDDEN>) id 1tZmAX-0008OR-6Q for 75170 <at> debbugs.gnu.org; Mon, 20 Jan 2025 02:25:57 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id CD5DB240101 for <75170 <at> debbugs.gnu.org>; Mon, 20 Jan 2025 08:25:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1737357950; bh=nRUGYtztV9E3nksumD4HR8ofFvriUF9Gp+Rtqn4LJ5o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=dxNPg+PIIXrm2Ntm6+UwscjoCvsRBPoAVAPjSQZ9GzpiwpETBGi01d+e4wr+1rjFy KRjchqK98n/c/QY9c8DlO1zts2z/4ZqhoBfDCc6Uit9yHO5orPQ+SphR4Y1c6xuMHE tX4U65PI5IRx2s9qnFf7RDbn34Cey8AkKbA8nBQCskYUAAt5o4u/EfhrhFrNJVSigt 6Aw1i/cLQuXdfpwhbu+UdIoh1ZL6gbx6vOfU/hUaAPx9Am/EUjM2qo+KriJp0s16C6 1cMR5e8uUeMCydOdOf6cOna6jrHfGrEfs4iav2XMZq3NBjcaYkOvp8w3nd4BrMhN5q xlYrhVOTQUtrA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Yc21l1B8Bz6tw1; Mon, 20 Jan 2025 08:25:47 +0100 (CET) From: Thierry Volpiatto <thievol@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87zfjmts7x.fsf@HIDDEN> (Roland Winkler's message of "Sun, 19 Jan 2025 15:21:38 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> <87ed0ydef1.fsf@HIDDEN> <87zfjmts7x.fsf@HIDDEN> Date: Mon, 20 Jan 2025 07:32:17 +0000 Message-ID: <87ikqaueim.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: Thierry Volpiatto <thievol@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Roland Winkler <winkler@HIDDEN> writes: > On Sun, Jan 19 2025, Thierry Volpiatto wrote: >> While you are at it why not implementing a add-to-(a)list function that >> add/remove an elemnt at INDEX in list? >> It is what I am providing for my users in Helm. >> >> (setq example '((a . 1) (b . 6) (c . 3) (d . 4))) >> >> (helm-add-to-list 'example '(b . 2) 1 'replace) >> >> =3D>((a . 1) (b . 2) (c . 3) (d . 4)) > > I am just curious: when can this be useful? Off my head, I cannot think > of any alists (alists that users my want to modify in their init file) > where order matters. Here mainly for helm actions, but I guess there is other use cases. It is not very hard to implement, so it is a nice extra feature to have IMH= O. =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmeN/AETHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvkzbxC/482/RGb6+hJAjAABE8Vt4zt8bUBuu8 URjPhpUoLMFyXSTih1ELBcnlEe/VB0/fRxMrYFTTj0H9gaQsEfndahLocVVODD1z u1BdhGgKu47VsQFW0m+PMP8pyagrtbwxOJoyCO8mP7/fnaU/tvGec0AjDWYoTmkC Hw4+EZc0hlPzhJiiY/D+Pj62xF32NGXpW6ZCopuNli7/lwxzHTV29tGwD49QJxVD cNumFK2G5JeJasTNEM0EXQwDNj9SV9wM4pvYpYSRbJeFKM14Eo078vb+bSI/mhR6 Ew73q3gXGXukUY96+g3U/iLCCn8GJwgvsuMyyxLqGP/wIYraq6JIQ6E6eHqNiLcC h4jXdaeQMy1Mqz2L6YXo5k8PLeVbtDH+USG82qRh9JhQVHsNnCamByZZ6VrAS9Oe gE6F0wkd/a5RDunr0FBMtBdsKV3GEMyeRiPx5lcT9SgsQMr7z6O5D6SjEQG3EasO NB6uWEDxWyorjXs8YZBH3iot48dOeyHWr9k= =1YM+ -----END PGP SIGNATURE----- --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 03:41:50 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 22:41:49 2025 Received: from localhost ([127.0.0.1]:48567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZifd-0003XK-Jt for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 22:41:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37422) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tZifa-0003X1-HE for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 22:41:46 -0500 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 <winkler@HIDDEN>) id 1tZifS-00033w-7l; Sun, 19 Jan 2025 22:41:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=i9MCehPN79b8mevaUE8ADWpjzHXpREh5+9bMpkVjqWg=; b=Hk3vOrX6S83Icufa9gvR Kq3qKBf2ZOVBJmfW2Tli7nb1VpfVADsHfitXI3d3+0SPCtcDpNQXkHpY54DxigKNH92z+OuiliLYi D0Y5Ed9pK9mUjPYLMUhvJMT7xMCSAIwH4ZNd2aMintafOOhe6sD7T7AoUYO1LrE8qSHZQFXmA9BE6 4mZqsa2QWubSYDouneHtLrjv1w+ApKOcytMs3vnrp0VpDgJ90f4aPfm+fQ9RiTWg9VsR2cHyQ+moA Gve1K6CCw7+NLyfLuXssgXOVb3Qemms1VUqjf5VaIk0tJLbeInC3qHo/KEo+DCWCBWHzosLXoPcOA zvPNGA6TzRA6sA==; From: Roland Winkler <winkler@HIDDEN> To: Michael Heerdegen <michael_heerdegen@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87ikqaguor.fsf@HIDDEN> (Michael Heerdegen's message of "Mon, 20 Jan 2025 02:06:44 +0100") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> <87ikqaguor.fsf@HIDDEN> Date: Sun, 19 Jan 2025 21:41:35 -0600 Message-ID: <87sepetamo.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Mon, Jan 20 2025, Michael Heerdegen wrote: > Roland Winkler <winkler@HIDDEN> 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.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 01:05:43 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 20:05:43 2025 Received: from localhost ([127.0.0.1]:48319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZgEY-0004fV-Lv for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 20:05:42 -0500 Received: from mout.web.de ([212.227.17.11]:52865) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1tZgET-0004fD-Is for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 20:05:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1737335128; x=1737939928; i=michael_heerdegen@HIDDEN; bh=ticME++cqsC4uLo4wpUupM2kn8mT8iajzXZkT8jRxk0=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=CS6Il/7kKbY1oBLlkn0jWwNBSvoFU1b5MfupCorMuMU3nv9LqiWszyg8b7yjudqn zUUFo/46HV+L9BJh3D8Gd25bi+ZIstRmS38UmnCiU6nnSyzyd89D0VConHM1U02ym nj7TVv//ewi1aa1DgJDCfnltg3v8p7sUMyhVSeHBHGbFRprMx1z9Vsxp1W5v7+j7v RC0ImqPQcrcPYUnLv0uajx507jfvKN6ynxb5y6Wk5NYdJgkGGeiQw3dHABkvtg4SG T1FLx9r331epWVPI9fTHTGZ2XALzjhJb9CPKVEm6/L+OeLOhIjfBG6e9LAN3oJyzD Z7Zn61BIoYfcKQg6Ew== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MJWsc-1tp9kV3xpQ-00N3Zt; Mon, 20 Jan 2025 02:05:28 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87frlfuy3m.fsf@HIDDEN> (Roland Winkler's message of "Sun, 19 Jan 2025 00:17:01 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> Date: Mon, 20 Jan 2025 02:06:44 +0100 Message-ID: <87ikqaguor.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:RTJEBSDZuIzLsIxggjR3p9ZPNL1gaZBcY3qcuURbB9Vqy0SkekN rdtonwCdIDS9bizdXFOpQ82VUnRgEaW3+MX1uqPOy2BjaDXfoH2kIXoBGX/2m4F+u7qgX2q 0VTr4O1uOVxzClvlEQvFKSBPs2k++Amxsmzh2hGJtSJTGM+aNMM3hqx3uPeWRJVdIRJKkAG sXp/DbCEw+vuL1XjqKGZQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:pxkZ7TLtznc=;oyVCtHUp00iorXW0B3dCWXT3Wkw 50FtfsLwJpHAHV7PdJAfsbajp+bZrY6A+aMRDnjKxe+V2WkySQaAKLo6E9916vTLkiq3cSKAW nh8RfowJEGPiZzyEHgqg7WiE65LOsZ444e2pRxz9UfnjSSIxqJDBTdyhzi8ecNGiZ2ifTWXvm NVob0/bWCAtFWvalA7UhrgZtgvy6r+1pnv9Cqe90U6KftZEVA0wpCYNKgvW05DNzZW+Ys+3QI Y10at8YMhhWE3XbfY+rbzeRosUw4ZAp6w3JHvHW38FSUU/abqx3fqfMyhcwFxbzjcVYvQnXx+ o2BELBpAqE8RjMLSMY4NIx+ao89BtotZ6O+dH/UCMl2nKNvsMuEah1DRH6NnnaaCuIV9zDox6 Re5grjMrgeDtHzT9+kP/O/LbYY/wE+1w+MYRaYD4YnebQQ0QEfgcwPYuQfpge+rp1gP5nHKdK kQ3F/hWVd5qevl7fwnmn2usqpHVWQ06naPx4vszwim5QJTGohjrarfxU093fuDOrQYEVKVQ0q BaaFOhoiEvP9huNzUDLgFbljhbj9sxwcNXNaOjuv8zsE75ymms1P5HtvjZIniCrwtNW4egOaZ R/fFTa1yNlVWH3iVSkr2SLAd3XB/79XrcqrcIMfpTGnEYLw8quyvmnFHXdgiSO3UAQGBPcgc9 HhDJXyiNOSyg9P6ccrfroYBo9WFG1bf2my0I8sd0puGQ04xbCz/uVzQNfOlfzm9kGyx8agLZo 1liAzDFNQ4Io1IIwjrRo7DK5OsI0WNX0ZM518NXTO0WeW7MuhlodLolvgXlT4+9XN/ly/sfMY Yx4/MP0sF0qIbidAXZ2D0DVa8h4r0ddP3lziDTxGcrm/FG68hvJDyifPIX2ViMWgDQ+94dqOl tFWcOHSkBcMgy3nwcqm32dO5M5/ElbRQjJ2cnY2dSSUtujtwkCjspY7LqW3jKp2sRW8b8Pyb4 B2y48K6xt7OF5dYS82xOubykQmzJrsvRaf5jggGsaCPLX6D7ekaOCEEPI4Hsz9FnZ4bWUHzjw BfDRCq3uJiYmlSaxwWl1sNw05lD4cHNFOdVC8quvTvp6psbPRgVbPglvgHeMAFoyT6tMwpS/J MW4bcS4nzsSzjE+RQ9z4U1lbK+GxLeTDS2YYkoJXIabtH6RrC6cH1CWH/Hf/NjoCfoBjylKgG 1+u+hFpZlLUoRn81g5E9kOr+GrFTYKGRPmagz2kcIhQ== X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Roland Winkler <winkler@HIDDEN> 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. Michael.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 00:52:04 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 19:52:04 2025 Received: from localhost ([127.0.0.1]:48294 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZg1M-00042H-II for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 19:52:04 -0500 Received: from mout.web.de ([212.227.17.11]:52169) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1tZg1K-00041j-Hl for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 19:52:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1737334311; x=1737939111; i=michael_heerdegen@HIDDEN; bh=3YR16T37jlb4zaagSmM3MkzBab8Mx9RE0TmD0EtjHY0=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=UlQ0pEquu3SFd1UoqlbZKq8D4/5jmDj6mhQcH6KmZMH2iB7EGoFuBYZLXCLWkwEN 2g3nMtskr9hl+iQPTT/2sH2u1jsdJJhXBkPfQtktoBbopNx2dvwoaaFZQQOFUcN8q Y3/fg0kl9ALVue48alyErTw6nX46mbhoRr3MQvL9VX9R+rzOxMiVQXAbFfAw1Q29+ 5nUjCW3A2f6ll/Ab4I49568ekhAkyuWgk/b0EsmDrrRhJLqMecrVsSCgIg60yG++8 EntXjnjTOnCdFFYAB49GFyiltS0/pj/sfTbcuBpaPB57TOnhSMp9CNlufeJX1M7jI hpHbWvq/xuL0WrSpAA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mm9Va-1t9AxD22m8-00jEFW; Mon, 20 Jan 2025 01:51:51 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> (Stefan Kangas's message of "Sun, 19 Jan 2025 05:23:15 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> Date: Mon, 20 Jan 2025 01:53:08 +0100 Message-ID: <87plkigvbf.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:smOyCL/9VrwKCfEERqDuyGAhNEV8qRjdanG4Xmvz4fialNieODs j4FVmMz8ipSgXvQ1+QZhfVKdLCAA+dr0FfSQ7qyW74tvjcax64EokKBPi2WeLwgy7SBAkh3 TULFw9NmUAIHjEUktd3hfguZhAtkrGtZ4kTAlb3YutdNhdPNREgGyVdG89XZpAma0Sy0WY6 bUWXTp0cwnK8837U0haEw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:tlAJaG79hhk=;pzwz+J+jgsiyG3oE+kuJwi54H6U 0U+pigsvF6MYUUJy/YN0MLLGkjBtQFZ+XhByObEcg1AnJl8YGV2Jh+vg5bcggyXjuSulUT2/O y7S2YU13PS1FdpMV+CndvJLZikrWFK0+1LJ1P3B+T17Li2u+BMAco1tiKvHF+OSF7tmD4zrn0 Ih1BdB8ystOMvAEJ2Gjjuog4gfWcbqfp1+heNl+pHtq2jTM/D+DPJlOHkufoB/DVoXWWmpb7p iaj/05KNDaP2o3L0zYcBywsqJbRYb0zkfg6rp/ZfZUJP/gNPQcwxMpPAm9o3c9rkGJC5/VxUS qyS5utZ9fJvFjy0g9IcnlbI4vRBO1YKIYmeA8cjFKogfOJNLUbxi7npdhh/Exy7+4s09akk0t p7npzYdZnmmC+Lt/kyeHpzdJ0Z1ACAYQrR1UNzU8Ixq8NGpQB18Fx7luz0bv1bVoBB1Ei659d I0nG4ey5K8uk4PQxYHqqOfMTvbaOgBx3ZikejtuIRueT9cC+TLGgJjLxtgXNnfbxAYTIH5R+Y D985UBywDBrlUE6TsnRIWxIVQM6QtbSfb6Fr4LTj4xDMAtqpQfKJxrXIjazxWPMMSbRsUZn4c 8gzlHBIePCrRPQd/lQW57injSNv7EVnLHfcuM9Pg2XaQCuTr3nK1LRPITWT1s1Yscm6+6aMsz 1vh4FL/wBt5kqSnjLgtMg413qUsz9jgnCL1IJ3bs0cXA2IZ3DqCS34rkDnJGB4/8ExWKzhMuc kYnq+qwRwBmJwzOKr5ZP98L4R55h5hrY28iGQ7gUrri9v6Zxv03SQn2YE3vJhf0YXjs0M0Y5L k7BA6to+dYdyGqA3CjOt1f7uDSt3Wb3wOsko25bFkcMGbQrhr0B5XbzvQ7QGABf2jhh1ieCCK 2800cA3ccL7oQDwm5nbhJGZmXOWj550aMIyFxin0yScPydEkqF0A5aHhc7sbcp6fTrq2UKXBz 4yyGZmA0VvYnEFq6gIjycFhp+NCzFCW2LmHIeRUdAhYGlbum6B4+aH0kJaRXhA9MXvqJt/CZf MFNNw/NmoKWCbIZZ2kiS5e8GQSA+F+eqvnxLhLF1YOnSONx7NstBOqIqfI1WGj80cVRXhAFBY J1DNNPmAdav7vYeHcKn7plDvSyUy/YSdlWFVvsRftXtQ+O4E16/LZQqyidV1/MJO9WfWYWL7N hFWJN3i10FV/tqOfjTk96LQFzLuF3DAMyyz+08gepYw== X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>, Roland Winkler <winkler@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Stefan Kangas <stefankangas@HIDDEN> writes: > On balance, I think we could add it. Also, we already have a library map.el that is another generalization of these things. Let's not add a third implementation. Emacs had once a library alist.el IIRC. Dunno if it had been part of Emacs or third party, but it had been quite popular. It had been obsoleted by `alist-get' and map.el. That's not so long ago. Let's avoid going around in circles and think twice about the final feature set we aim at, and how we can get there. Michael.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 00:46:19 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 19:46:19 2025 Received: from localhost ([127.0.0.1]:48287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZfvm-0003nQ-Um for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 19:46:19 -0500 Received: from mout.web.de ([217.72.192.78]:38875) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1tZfvk-0003nC-IU for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 19:46:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1737333969; x=1737938769; i=michael_heerdegen@HIDDEN; bh=QTeKMwhx2XWUcESZHZv1OpHt6cd6QFFrikvXA3J6cSU=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=DgfO8+KfTC1BoWhxoMriW4UXCjC95vfDGJc1vAYHwEOqmXOmYlDOMXhAJUVTp1JU 6kUhXPgFSWOG9xr+1tMQlTaSQfwaJ9oO0bX3beunYxg+zim+v7ye06P1/aPAteqxY TBPGlPMIyUy803Nb5Xb/0w7RWbCDX36rpFRKj6DmLEncwvBhJtTTU/CeOiUnyZtJk XoYUWMTgKlxEP4pt7L/BIvd3YJNJlEcVivyDFsHlHddh3V4Z1BtZ/V1sqbh+FZdDt xvRMZnxLwXHlUmuSojL9h9lkajYtQBwV0TolbZ0Fps3//AYw0w9ZG9tz6DCiFDmd3 4jwm8L3/vK421mAR/w== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MElV3-1tkxfm2GbL-008ytY; Mon, 20 Jan 2025 01:46:09 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <874j1uv6yj.fsf@HIDDEN> (Roland Winkler's message of "Sun, 19 Jan 2025 15:17:56 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> <87v7uaa97f.fsf@HIDDEN> <874j1uv6yj.fsf@HIDDEN> Date: Mon, 20 Jan 2025 01:47:26 +0100 Message-ID: <87tt9ugvkx.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:q7OKU/FWmJmxUgsv/kqImYtRL1QKYa7dWj1x5pCI8UALHvkE2W2 ubDyim+HPWcJbOW1nKQys8dAx7U6MFWjlzzrJnMVhhaVgDEnecUs1SYWBK5FbjqUe+rycvV jKi0ox7mO/EroJr6bGbPDiTi8+MQR3OSJQBbc3tsZbyxoyRB+C559jqZYGoU6rtfUnKQ/kb 4eJGFrVy+a+xrHEILHIew== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:bgV8Zush/gk=;QkkW8taVRGCJ2pfFC43zjghn8Fl ITbzWnY+6+1ECtyZVGqhQT7epPdMCNdFtct/43h8PapCo+oS5kLoc3QDDrgmYowJLTFVD0UKg 6F3bimt/IhRM3r5f9p/HXU6c15mQtoEb55KmErhSs8J28vbI1LtcyMQZ0TuSh+NVPRhjvPV2s qz6J3vZfWFLuoUWvxiIJ5QPX3vHWI32ErLnWCP5GlA5rW8YkUs5b07Fa0IRvlfREJ6wTVTIND LqGImJWwlt22Bn0cUqPFf8SkdLnbS3VuJ0d2MxpD4c+BHiLS3IEqahPmD6zwQC/DOY+pH0C50 dJlXXp+EdhGer5fKvSwHRu+tS4SVXV+CeQX1XtFrNbP647pZMHSF4CsbpESz5mMTWfFJGCwA/ tNXq0uZd2yF+EX3MSJWqtVQr9X2bpaAkfCKyDvXjjwjRgL/nU5gGVj79qVx6JXP6U3Fv13Max MZOq6Vdct20FG0EYTP2VYwSZUNmrsWboD6w3HDhWKbU/S3NyYzbae5vw0rso2/4CbawZQteCL eD3LO5mAOzrjWD4uvMjknDVn47f8QOPcyJad+BBWATa2+EhTN6xlTT2jBTVQYFts8UnwETJ/a frd6n8ISXyph6C/tqmcQKD54ubDBNdOGOHUlUh9eSn5cZ69oAN7+MJIvRPavvGUlGBw9/NyqZ 4o8Lk/JLHhYQIesTCnSy9/Hsv6/UAruRUkr53HGaMSnoOlWzouDwABFuKmq4vER8r8jy4Vm1L g1XKBs90kOLBIrEEVwXHn7EK2aDt4DUHJGuaxfVzxfosasIIUsCKA3r9FpllHe7PsUwFmy/K8 GHblS9Y4RU/jXyz9GpvxE/lhu/SMPE2BB0a2ZrAWkfaaLfC7G/o9qI6s7e6KgtcKHwgI+0aUw bFJoUlGlnqPWowWb73mGvDYcKtysbcrS85bj7DC1DM8sR7gQ4isj9QzQ5+682pAy7DVCFS+z0 WkN/qte8S8kzVaf3RVKWlAVpDqZC5ugetESiV8pWWq9qHZ2hAJbzSZ2eVDsAlYRPySX1QkSFb KbrI5AbMRpaHoC4lI4tAfN2xIGCi7G4YQgbWmT0OshndP5K9UHoEitqqfr8OhZ4oflANT7Kft gFO0bwcSlQYBxWYCe78q8GLLf5qPMofeQNyWda9rJLvUju0kS01BLOGuIJMNdCdCz0uz7ohVh PvflPxk8N5uVNaDZt9DYZjcrEjEZla009xTdTg85OsA== Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.7 (-) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org, Juri Linkov <juri@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.7 (--) Roland Winkler <winkler@HIDDEN> writes: > > The no-replace argument is useful for setting auto-mode-alist when you > > don't know whether Emacs supports a particular programming language. > > For example, the following suppresses using text-mode for m4 files in > > Emacs 19 but doesn't override using m4-mode in Emacs 20. > > > > (setq default-major-mode 'text-mode) > > (add-to-alist 'auto-mode-alist '("\\.m4\\'" . fundamental-mode) t) You can already do something like this, e.g. (unless (assoc ...) (add-to-list ...)) or (cl-callf or (alist-get ...) VAL) Michael.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 20 Jan 2025 00:28:15 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 19:28:15 2025 Received: from localhost ([127.0.0.1]:48262 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZfeJ-0002wN-0q for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 19:28:15 -0500 Received: from mout.web.de ([212.227.15.3]:43753) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1tZfeH-0002w9-CT for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 19:28:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1737332881; x=1737937681; i=michael_heerdegen@HIDDEN; bh=kmrYSiDZSk2asrEjc+0KUmmbJUiGgLFWC1S59aQUQzI=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=GQ7qe19sP9Bq76aubzwrdersv8K7dSNEJjzwCvCrvRO2WfpS72wCBTZGnI/4sCz4 3s6bOIRXsc+UB4TC24Dc/sDiEFnyYowKP3atWQbP/gZeF4EyahRfAI1dxoLyId6vC 6/5IZB/g1LEPzZLh4UNETEKJt+U041qp4zjp7vGdF4Qubjx0/Jnmsisyv6JrMQQvQ bKNbPQCXc2dxTKXgOWIYK0bQoT0bUIk5icQMd11Ngyze5hAHm6tGN4CZvON2izOpV m0nHfv6fbzuaZCDEhqfXPwRS2lPTJyd+zOjwdOxWNLehFIMboPU2H890UkaveDfjd b9OIOhkv9Iiy3qqXTA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N0qqv-1tL12S0vf3-00tgO8; Mon, 20 Jan 2025 01:28:01 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> (Stefan Kangas's message of "Sun, 19 Jan 2025 05:23:15 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> Date: Mon, 20 Jan 2025 01:29:17 +0100 Message-ID: <871pwyiazm.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:ME9TZByIzqjUVl3TylTw50AxSUwTLgGV70j1Ve/gO0nZbN9b84f 9KvK1lCGYIqpBDU7S5WmK7FwkSdto5sL6D5YUAmsoitHkEwkT3qS1wtsl7qQF17HGhxT9P3 vOwbluof2jbgVpC4Gkabz62CKC2T18p4pYbUJZBG4c6lPzKwSTm6F2iGbrjiM25Uiyl/4XU Iynk31ZdWHN01OVumAumg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:UBySQ+RAsOA=;tWP7NeR020Mgtpv9iex1aagN6n4 IJA+u9N+p08cI0Yerdq8wvPOSLV1Vx9RjlbOKAC59BXJS6UBsVwSSHzjgC0M1TQAMVz6Qwbyn O9TmTLzmKLu8ezQCGCQKYdhULj63j0No9w3gRVfazmS+fFqroUL2C0ngH5JA+pwJpCtcTXSbz Mwd1kh9ttG/Jm+gjhrmWOvBnXexWdqq1ZpRV60A3dhvSx2rndorh84gWBQY1IrZ6LP9KgWGS4 VIndiKoZxxmEyB8XPLkMjHn9g3bwUaIA9wx3A9SbWZDl8xKAiGNWGahICP+XeGzn0ufgZFqgq K6qZniGT+bwtNt51X84Xk5JtXZ9AsUa/LgEq9R+68BpmKBH7CG1clCaoS5NJU4gt5kNKiH+mF 6OQ61t/m5VLf9J/E7dnWEErXo2U0f/QJ8VfECwIIlDngDFvtiOcWzHwQCoU1+8CfwusfO0Mc5 MUV1u1YykE4WNjHb86bF0hGuEx3/CiK4PPSip0ud0XMAieGznd8hAcg3675okYGqtckeKV7s0 NgQw6lFIUJjd2it0OhyYb+HtAflX9mWmrkStLa+IabXJCU7w10T4zkuYVNiP8uQElx/3oISH6 IXLjT1aVXXFnzoHfgrDuY3JYqhOi0kjtsgwIejwcbDs8CWkDhOz+6/MsVpjR+odkzK/m0wFA0 /Fa4CthvT+Bho9hwqKutuG+assQcJksJ54LYE3UW414axfm0o8dIhKFcixHk3cYco40FZ93Q4 ZNlMXDJVYcR2Xwju7cw62D6QhRP8+CFwLYMllMoKeMRQIp+mhHuCxOqOwL3ZWN9xlyhvZmaw6 Prwu6c3PGquxZ6RqhqBpuay7c/DhGBfcekhQs4YjcQaZG/DEr5inMm6UbKPab0eIUnFxMqcX3 fFPpHrb+tXk6dL4jdm1hit9KGMkwOA+iy0Y6spVPQvL9nYYuYskJcpXB7z2oqjpDkXX0B2EZI 2pJGrKxITr9MEtO1b1ZcsnakP0L87I6LmMofTX+0srTvXqOdpzNGNsZhxFfCbkYQ61LqE05Ba EwcqXYXnaWqvb5lnBr5dXsxh/GtonVE+D33lFlyNdeb+wbpFlZOB+aWuIJVxPir40DRQ7iaia N0a7QvXF2hge2ofZC6A0zfeGk2vd8pgfTY8b1IGCmYyebgOYqeBDt6ph83DMKPHLvsq5ik31y RudC6mqOJ9LxTPVK7dSGDtClvMfSxgStJixKn84YALw== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>, Roland Winkler <winkler@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Stefan Kangas <stefankangas@HIDDEN> writes: > On balance, I think we could add it. But we should definitely have only one implementation in the end. BTW, this situation is similar to and-let* vs. when-let* where Stefan wants to remove a similar kind of twin. If a new construct doesn't provide some kind of advantage we blow up the language and make it more complex. One has to remember the differences between the twin versions. So, are we sure that adding something like this is making things easier? What is the advantage in this case? That it's easier to understand? I think the examples in the docstring are easy to follow OTOH. If it's the discoverability, then let's improve that. And if it's mainly useful for newbies and initialization files, an idea would be to start a new file init-file-helpers.el or so that aims at beginners, and add such things to it. Michael.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 21:21:57 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 16:21:57 2025 Received: from localhost ([127.0.0.1]:47631 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZck0-0004r7-WD for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 16:21:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46254) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tZcjz-0004qs-19 for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 16:21:55 -0500 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 <winkler@HIDDEN>) id 1tZcjt-0002FT-C4; Sun, 19 Jan 2025 16:21:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=vJHlXYx5EdUHK2NAQbJc0lpzI4pHnr/XKxqrdM0UcyM=; b=lGbNDtnfM60QqTYUMNUI JTUF3xwJgI4iww6HFH4d+P9Hr3Kq01LiVZJogcKn+8F7hl1npJ5Erhwn1CSPWrJpo6N1O+UYap2gB vTmztSrWFns9sP11aksnxbi2fvdbTJwErH90Sd2XAdBpo6lkYEhcmcYPc5wFDLwPZOozSYyFU5Iwk w/matUTDE43lUgpEsig3RtlnoCa8yiMFSFIWlIauIQgrqCdRFKWjxdtuVAyV/Dl8b0+qn8X1bw5Va f2qO4qWCFcFUC7UTjjuV2jHJEWbrcIQDKbOUz2xih22K30slc4JysFxsX7g9FCNlI6r1YtYEd+JvO 1kS1V1r/9/L4VA==; From: Roland Winkler <winkler@HIDDEN> To: Thierry Volpiatto <thievol@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87ed0ydef1.fsf@HIDDEN> (Thierry Volpiatto's message of "Sun, 19 Jan 2025 15:14:10 +0000") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> <87ed0ydef1.fsf@HIDDEN> Date: Sun, 19 Jan 2025 15:21:38 -0600 Message-ID: <87zfjmts7x.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Sun, Jan 19 2025, Thierry Volpiatto wrote: > While you are at it why not implementing a add-to-(a)list function that > add/remove an elemnt at INDEX in list? > It is what I am providing for my users in Helm. > > (setq example '((a . 1) (b . 6) (c . 3) (d . 4))) > > (helm-add-to-list 'example '(b . 2) 1 'replace) > > =>((a . 1) (b . 2) (c . 3) (d . 4)) I am just curious: when can this be useful? Off my head, I cannot think of any alists (alists that users my want to modify in their init file) where order matters.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 21:18:05 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 16:18:05 2025 Received: from localhost ([127.0.0.1]:47621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZcgG-0004f6-UH for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 16:18:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47410) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tZcgE-0004eZ-BG for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 16:18:02 -0500 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 <winkler@HIDDEN>) id 1tZcg7-0001hy-Vc; Sun, 19 Jan 2025 16:17:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=4Gwu5SietDxNd8UHh6SQ8x4TZSQATiszPWwhS39pI1Q=; b=iVtPnqeg/gYTWgCtogLh x3ylAezhG5/HEL7lc3CcEIosQB2sJf44BF4pj7PtRR04hc0OLsBQO4Ht3z9j9rX/7da0YhiLjvjQx clNviuiu5vEYG9GhKvsf2ezkU791H2wyHmatMT6nsHc6O+RqtM1Cab/vxx6fzljmkmexY3j7Ey4Rm 8Jad9LIs7mzt0D2GMVbo5DaenZRss43EdDKn16pHcyaAleN9wlI7XBtNZejzNMQRsXVBnoKNNyyX3 LL7MytrdL/r3NiQIiOirTF6UhqbZ9lFB22/C1Z9zlza1/VUJzzQN17PXuPRwNkRkgQz9P5JLJEMh8 YObar0tjUhNUYA==; From: Roland Winkler <winkler@HIDDEN> To: Juri Linkov <juri@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87v7uaa97f.fsf@HIDDEN> (Juri Linkov's message of "Sun, 19 Jan 2025 21:35:00 +0200") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> <87v7uaa97f.fsf@HIDDEN> Date: Sun, 19 Jan 2025 15:17:56 -0600 Message-ID: <874j1uv6yj.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: Michael Heerdegen <michael_heerdegen@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Sun, Jan 19 2025, Juri Linkov wrote: > Isn't NO-REPLACE equivalent to this: > > (cl-pushnew "statement2" (alist-get 'sentence (alist-get 'c treesit-thing-settings))) > > that results in > > ((c (sexp (not "[](),[{}]")) > (sentence "statement2" "statement") > (text "\\(?:comment\\|raw_string_literal\\)"))) I am not sure how to read the above example. But it seems to me, it is different from what NO-REPLACE does. (Anyway, it is a piece of code that I would not want to suggest to users to put into their init file.) With NO-REPLACE non-nil, add-to-list will add a new association for KEY, if KEY is not yet a key in the alist. But if the alist already contains an association for KEY, this association will not be modified. Stephen's original proposal illustrated how this can be useful in a user's init file in the context of auto-mode-alist: On Mon, 12 Feb 2001, Stephen Gildea wrote: > The no-replace argument is useful for setting auto-mode-alist when you > don't know whether Emacs supports a particular programming language. > For example, the following suppresses using text-mode for m4 files in > Emacs 19 but doesn't override using m4-mode in Emacs 20. > > (setq default-major-mode 'text-mode) > (add-to-alist 'auto-mode-alist '("\\.m4\\'" . fundamental-mode) t)
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 19:36:19 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 14:36:19 2025 Received: from localhost ([127.0.0.1]:47496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZb5m-00054M-SJ for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 14:36:19 -0500 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:50209) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1tZb5k-000548-NW for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 14:36:17 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 56F901BF204; Sun, 19 Jan 2025 19:36:06 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87frlfuy3m.fsf@HIDDEN> (Roland Winkler's message of "Sun, 19 Jan 2025 00:17:01 -0600") Organization: LINKOV.NET References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> Date: Sun, 19 Jan 2025 21:35:00 +0200 Message-ID: <87v7uaa97f.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 75170 Cc: Michael Heerdegen <michael_heerdegen@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) > I just noticed: the docstring of alist-get is much more verbose > regarding how this function can be combined with setf than the elisp > manual. So extending the documentation of alist-get in the elisp manual > can already make a big difference! Personally, I always find typical > usage examples in the elisp manual most helpful. One typical usage example: (setf (alist-get 'sentence (alist-get 'c treesit-thing-settings)) '("statement")) that replaces the value of the 'c' -> 'sentence' keys in (setq-local treesit-thing-settings '((c . ((sexp (not "[](),[{}]")) (sentence "\\(?:attributed_statement\\)") (text "\\(?:comment\\|raw_string_literal\\)"))))) > Also, it seems to me there is a difference between add-to-alist and > (setf (alist-get ...)). It was already Stephen Gildea's original > proposal from long time ago to give this function an optional arg > NO-REPLACE, and his proposal included a nice example for when this can > be useful (copied in my first posting). It seems to me that > (setf (alist-get ...)) has no equivalent of NO-REPLACE. Personally, > I have not run in a situation when I had needed this arg; but I can > imagine that it would help others. Isn't NO-REPLACE equivalent to this: (cl-pushnew "statement2" (alist-get 'sentence (alist-get 'c treesit-thing-settings))) that results in ((c (sexp (not "[](),[{}]")) (sentence "statement2" "statement") (text "\\(?:comment\\|raw_string_literal\\)")))
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 15:07:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 10:07:52 2025 Received: from localhost ([127.0.0.1]:47109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZWtz-0006ON-M8 for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 10:07:52 -0500 Received: from mout02.posteo.de ([185.67.36.66]:54733) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <thievol@HIDDEN>) id 1tZWtx-0006O7-5M for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 10:07:49 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 980F1240101 for <75170 <at> debbugs.gnu.org>; Sun, 19 Jan 2025 16:07:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1737299262; bh=wz4gXYwgLe8pGqAO9gVB+e1RCyM2QgDpZ6PvoFujUD4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=I4ssxzMYzPePfCh5VmGHFfx5rgmVr96vTgy6ZvIIgy6B3Qje8HYxmx/Z5aQEkK4qI 0tkd23pCOW3r+OhhkTQPxXKvNrM9l7jndtEvcbHbHsqeWjfDlrBmDM9fwak1pmoFDJ v/Z8Oeu3G+qFkX+ics89WOwYqd7IaxYr/YzLCT5B6ejHnJbJkonnaLU4NLn7p7kXUw kdLSTnnPGpvgcikiXdmYESr09YLSe1+tweupwgaRKKDHnmfINdhEtvmkAyhx4Eo9ak gA8C1lXkG/+Mr1UYNzimlW43DpxC8DGE1IR+BIxrjV9DCpk4kiUPYVmP/s8Wonj6fu FlDeNmquxs3tA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YbcK80qczz6txc; Sun, 19 Jan 2025 16:07:40 +0100 (CET) From: Thierry Volpiatto <thievol@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> (Stefan Kangas's message of "Sun, 19 Jan 2025 05:23:15 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> Date: Sun, 19 Jan 2025 15:14:10 +0000 Message-ID: <87ed0ydef1.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>, Andrea Corallo <acorallo@HIDDEN>, Roland Winkler <winkler@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Stefan Kangas <stefankangas@HIDDEN> writes: > Eli Zaretskii <eliz@HIDDEN> writes: > >>> From: Roland Winkler <winkler@HIDDEN> >>> Cc: 75170 <at> 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? > > The benefit here is that users could more easily replace associations in > alists. Superfluous associations are not the end of the world, as > `alist-get' will anyways only get the first one, but users might not > know that, and it's less aesthetically pleasing. > > If Emacs Lisp was just a programming system, then I would be against > this addition as redundant. Since a small subset of ELisp is also used > as a kind of "customization language", I think it occasionally makes > sense to introduce even redundant constructs, provided that it makes > said customization easier. I think this might be one such example. > > On balance, I think we could add it. While you are at it why not implementing a add-to-(a)list function that add/remove an elemnt at INDEX in list? It is what I am providing for my users in Helm. (setq example '((a . 1) (b . 6) (c . 3) (d . 4))) (helm-add-to-list 'example '(b . 2) 1 'replace) =>((a . 1) (b . 2) (c . 3) (d . 4)) -- Thierry
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 14:34:16 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 09:34:16 2025 Received: from localhost ([127.0.0.1]:45337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZWNT-0004Q4-Lg for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 09:34:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56650) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tZWNQ-0004Pl-7Y for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 09:34:13 -0500 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 <winkler@HIDDEN>) id 1tZWNK-0005vd-CL; Sun, 19 Jan 2025 09:34:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=AGZebGhbBEItxxHTZBi86N/5i+dWkbhgUEFD9nXPJ2Q=; b=Whn/6SPTP1oSkdHww4IR cz2S6HCUcFg+biaQii1nAVUD4hzmbluvTQeSNE4HL0bgAxO4djIppUa/mWXtwTojCOs+tvTzmH+UY BnrfR59x47TMRqHE1YmyLkd4xw6AVdBYNvvSSr9gI/IqDEUWQ5q1zlb12xT/sToZQsOg7i8IT4pKB 8Jy5kGeZzNc36VSdAS9d0EhpUeeqMmbzE5Mg9ZMVDNU1fdX6xyfJcAu1ElGlmJ1Hyf8xpcZoaPLpV 0X4F3Q0kGJWSR45ZYqSLV/4JOnWsS2JS4w7EhDmGhl2obTMKk0YZLrWicW1hvh59KHQgr1W0yk/j3 XotSRrQoLbB7aw==; From: Roland Winkler <winkler@HIDDEN> To: Michael Heerdegen <michael_heerdegen@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87frlfuy3m.fsf@HIDDEN> (Roland Winkler's message of "Sun, 19 Jan 2025 00:17:01 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> <87frlfuy3m.fsf@HIDDEN> Date: Sun, 19 Jan 2025 08:34:04 -0600 Message-ID: <87bjw2vpnn.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Sun, Jan 19 2025, Roland Winkler wrote: > 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? I tried to figure out what the optional arg REMOVE is doing in alist-get. While I find the code of add-to-alist not too difficult to grasp at a glance, the optional arg REMOVE is ignored in alist-get. But it is a more complicated call of gv-define-expander in gv.el that seems to define REMOVE. For less advanced users, this may be an extra barrier to put such code into their init file.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 11:23:25 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 06:23:25 2025 Received: from localhost ([127.0.0.1]:45076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZTOm-0005xQ-Na for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 06:23:25 -0500 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:45336) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1tZTOk-0005xC-JH for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 06:23:23 -0500 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5db6890b64eso5924821a12.3 for <75170 <at> debbugs.gnu.org>; Sun, 19 Jan 2025 03:23:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737285796; x=1737890596; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=4K2rUF9h+D2dxhnqX7J2vsr8APj2vis4k3FGxDcos44=; b=jM6psGLayFK19o7RMufB+wbt+1AATMrf8gsk4qYuncMldN/FNbG3HA5XhIjrnm3spG OkcJ/WWI8GWkflPC607iDDoGGn7FcCvLKDB7r7Sy4zc2/ccN+t29YOtywRy9eaTcKoeH PTjNZQea5Q85IiW3Tnev392s8NGjaCn8Omeq23+qlK8H3lqGsG2SRH9/MD2QVIo3BVpa Q14oD5v1U9kxQAIKDjn6PQnuAP2iY8gt073uqR1+zZGJDAJ+AXwobK5ns/2pbrbTFvXe g3FCNWwRrc1kajJjNwJmuU86FtfoQFuQ41k1pOGSgf1MMB8lsbpnK2SDandUcJ7WGiOY XWOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737285796; x=1737890596; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4K2rUF9h+D2dxhnqX7J2vsr8APj2vis4k3FGxDcos44=; b=IdcgrXpXtl4luDtJnoxTMte4kIqWvB7otrU3q4kvQPcN1KedS9gJCwxo4b4UTsa4GD ZtnwQlzySKnx7VLqMNNJuktO1kc70ctxJcDOFnnYXZAgia6XeQ2EN1RzTXxJVwtL1DGv 2hdQ2t0LoghTlSv37PU/UBWGMG9JetK0xs1tbsGzOp6zy+s2wd1ngG67TTPg2ZvWmZnH AfGXihFY8d27lawssB9LwIFdIZS+LdNlMst2Dd6jA6cMEeVUP3sdmsQdo7W8upd0+AuO uaq+29F/jg6Eq8VNW3vA5BPB1uxTCmr40Wqd155r0my/oY5xjAERfREervgynRuiBXFR 51sg== X-Gm-Message-State: AOJu0Yw3Cdu7aSmlWlpbx1QajyuwCXPWZet7MSP+JyKKahlxqi/pj0gq znMAjk6oVqQD6r6juhFWKw6N25/62AypAPiRi3U4wLkc9WoPmWg917fncCTX9/Oz/mLT1SVNI98 CR9XRq6v0I8ejk33LEkL8kqTf7xZKXykI X-Gm-Gg: ASbGncsRCYO5tWPvZvF1zwc0paa5PSgHb43s8QJcLBZDiV8Tbzu5iPHsDbXIFXQYJ7S 2FcKk8nFjfyppsHaoYJ/LNy1tAieuQjL8hXkm4qKOMqjCyiOKl6W6 X-Google-Smtp-Source: AGHT+IHDHEzSZxi9Az7jUV3rm3yihtcn/jl5CgUiJqGFeswO1wxrElmCPlL173RUctCgz9oyeeZJwYkbrwf6x/D085U= X-Received: by 2002:a05:6402:268e:b0:5d3:ce7f:abe4 with SMTP id 4fb4d7f45d1cf-5db7db06dd7mr8269829a12.25.1737285796013; Sun, 19 Jan 2025 03:23:16 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 19 Jan 2025 05:23:15 -0600 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <86wmf970df.fsf@HIDDEN> References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> MIME-Version: 1.0 Date: Sun, 19 Jan 2025 05:23:15 -0600 X-Gm-Features: AbW1kvbBaW7UV69oxmkNei3-yqCnenFq_Vh3Ou6LflqJ-Pazbyd1Vc-k1zpKFJw Message-ID: <CADwFkm=LOjJiKLohvEwguwcAODSDzX99oeqwip2QemR9wpG=pA@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function To: Eli Zaretskii <eliz@HIDDEN>, Roland Winkler <winkler@HIDDEN>, Andrea Corallo <acorallo@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Eli Zaretskii <eliz@HIDDEN> writes: >> From: Roland Winkler <winkler@HIDDEN> >> Cc: 75170 <at> 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? The benefit here is that users could more easily replace associations in alists. Superfluous associations are not the end of the world, as `alist-get' will anyways only get the first one, but users might not know that, and it's less aesthetically pleasing. If Emacs Lisp was just a programming system, then I would be against this addition as redundant. Since a small subset of ELisp is also used as a kind of "customization language", I think it occasionally makes sense to introduce even redundant constructs, provided that it makes said customization easier. I think this might be one such example. On balance, I think we could add it.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 06:17:12 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 19 01:17:12 2025 Received: from localhost ([127.0.0.1]:44573 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZOcR-0001hG-IS for submit <at> debbugs.gnu.org; Sun, 19 Jan 2025 01:17:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51724) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tZOcO-0001gz-MC for 75170 <at> debbugs.gnu.org; Sun, 19 Jan 2025 01:17:09 -0500 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 <winkler@HIDDEN>) id 1tZOcI-0006xL-NA; Sun, 19 Jan 2025 01:17:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=YKcSPGRhjCUXB3H5+HmKWygAnk1K6WPu2ZRarXYMWaE=; b=MxXtE/6IPq10+pLkGelN 2xtPRJ6byPq+1d2iXGP2+pD9LDTHYKjTNE9Vl+0EVtY9wapYeEZu2OkoEc3/7nFX89WF7C2WXR3XR YwpUekzaAW0IxHAWFCb8VsNtMTRA0oi7f7bDBXB3tsyoVZnyrhBqXfZSHWksG6nZYzecyuSvjux64 rGcQCJcAzeftrdeCHSHO/A+qj9IyscpuixdrKIWysc0inSn9t3iEPgKHLJjMNbzHLKMHStV1AGu+5 +ZrU6BKxybC45Rb7q21UtbOGyVUZ7Q/3ccdN6wREF1SAzAUZeOGa2Jgf10B1MsfnPYSUtDXEvlofx Rao7m/v4656VBw==; From: Roland Winkler <winkler@HIDDEN> To: Michael Heerdegen <michael_heerdegen@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87y0z7r1c5.fsf@HIDDEN> (Michael Heerdegen's message of "Sun, 19 Jan 2025 03:20:42 +0100") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <87y0z7r1c5.fsf@HIDDEN> Date: Sun, 19 Jan 2025 00:17:01 -0600 Message-ID: <87frlfuy3m.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Sun, Jan 19 2025, Michael Heerdegen wrote: >> 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)? > > We indeed recommend using (setf (alist-get ...)), IIUC this is _exactly_ > what you were looking for. Your patch contains an implementation of the > setter of `alist-get', and we would add a duplication. > > If you did not find this thing, maybe we need to add a hint to some > chapter of the manual? Great! -- It seems, indeed, the code I am looking for does (mostly, see below) exist. But the "We indeed recommend using..." can be improved. It should appear at a spot where not only advanced elisp hackers may have a chance of finding it. But more average users should be able to find it, too (say, as a strategy for modifying alists in the emacs init file). I just noticed: the docstring of alist-get is much more verbose regarding how this function can be combined with setf than the elisp manual. So extending the documentation of alist-get in the elisp manual can already make a big difference! Personally, I always find typical usage examples in the elisp manual most helpful. 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? Also, it seems to me there is a difference between add-to-alist and (setf (alist-get ...)). It was already Stephen Gildea's original proposal from long time ago to give this function an optional arg NO-REPLACE, and his proposal included a nice example for when this can be useful (copied in my first posting). It seems to me that (setf (alist-get ...)) has no equivalent of NO-REPLACE. Personally, I have not run in a situation when I had needed this arg; but I can imagine that it would help others. Roland
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 19 Jan 2025 02:19:41 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 21:19:41 2025 Received: from localhost ([127.0.0.1]:44332 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZKua-0006oC-U2 for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 21:19:41 -0500 Received: from mout.web.de ([212.227.15.3]:48937) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <michael_heerdegen@HIDDEN>) id 1tZKuR-0006nj-TH for 75170 <at> debbugs.gnu.org; Sat, 18 Jan 2025 21:19:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1737253165; x=1737857965; i=michael_heerdegen@HIDDEN; bh=kv0vNkviVdRaf3HdDY1yAOGddqcmfTmGqTC14lnKddw=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=mYh/w5trtUMfR5n0E+yqVxogOgGHplSX7kmBQBTuKvn6ljtuQXs1J8IKjJ6beu5V 1mG1atWxatTluSLDkhrySFOQBHB+P6wNK/yUuvQm8G51e1EacyWE6tIsVGcimezh9 iVR5kBvP49euOqQflmcdPwVEmnimXk8wA9+dkgfqdWA2sD3QBFq9P7OqFrZd4Y/+F KO0xCam6my1JHdigxqhsO5W7F8UV1trOF2SCsMKzbUdymiAILLR5UvOsaTFUHLfQ+ psQ3nRTKirr91CjZ0vc2hHhuR7PFprvOfXShONB2bHbC011vF3gjp55wdBTNlZ3i6 tPhGivbPhz+K8CpySQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from drachen.dragon ([92.75.138.197]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N1d3k-1tONef1lTk-016HBl; Sun, 19 Jan 2025 03:19:25 +0100 From: Michael Heerdegen <michael_heerdegen@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87zfkelf11.fsf@HIDDEN> (Roland Winkler's message of "Sun, 29 Dec 2024 08:50:18 -0600") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> Date: Sun, 19 Jan 2025 03:20:42 +0100 Message-ID: <87y0z7r1c5.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:6ndLokPNC8hekMmHxt1CXt+fKvZ1V12l7E2n0TYtjL+CEloBmaJ YRXFPLauFhP3ba0Ggx1Y1OU3zr4Hr03GT6V8yk8yJgzAaSO0T7jS0wKr0nZvwEcgqzSehCW yVODsG1xEO5RYpKB9bAKJnx27Vy3Rb+n6IZT1KviljYk9+7P3tDCclEeWbdAPtxuEn74Flv vAItDLDM3BEl7k5OsPtoQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:rgL1mMHkyLM=;WoRrDLxfWZD3bPlLK/eTqTAC0pL VMht0GSKiNXgknb5dJSyyyapdABR3ykd2eacYqCBwZ3NkKzyzA6NGX4zyyNSX5EAO7MFJ4Isz xW9tP/cCB6j7ANxPlrByJSqiVLbSdazYkt63IzG0og5ahwakDt8vO7WPEVX5LHh3BDFgFD2C0 ZlSwyJeZC3Xm7cGuqLQmQyTiYsZmVep2wZg9VaZwkoSKSrjcigHd7uqIgDG+8p9ZoAToT8dE4 7+uu03Rg7X8FjweK/vcLEVJQp09FIxr1KBvE8Gp6AL6MMM7sxFnHpxEPIy5XHUuHdONKTLlXb 9hXLGb9bSsxGg6V8ee7dgH15miyjSNaLJ2eD8R5yfiNZL90ZITlA2W1fvcGXkPWkbKfoLKy3M 04zzngSs5keuUuZbE2L441VAqqO2e5TA3Y2QAnI9l5pXqO8PWLplYOogP0BDtqWwmOWDhE2l/ /4Ly3iU5DlvlDaZL78tS0VIuwon7JBbrY8okrV7+hK2e1G0oxANblmGVeFDROBwXGSow+bjxG jwaNQXVbanHbxevVsMTb9yarMJm8vn7PIlZm+TzfPTsP6M46i0roDFeaPiG3QwPIzkS9Kww9Q ZR5YW2msWjEBUhJcInRXGBo9ZxYMJ2zj5cGlJFKUqd6wQasVyASQZPqaAiNapF2JK2RvWicdu p1s5zr3mfZ8TYABFdCF7CQIxTH1DT5mcs+EDShYw94vcgC42krOYNHmmyJtXu8QXrr5duJLwi b3KdSIqOUaDbU0sGEwkec53Frl8kAH1L4uvNEI7nYHeNzpLlBo2ns8zP0xXFQM/fuPkpK58UQ bM+0D1WFRadVg+DPH15GtR/8Gg60z5/yYRaxlqIVqGK7/NdUd0yO5iKqgSGNBAViuvEhwUepD +v+nASJOcd+BAZEAFMca9JFNjwaZO29mDss0hiZDZWHWti2g1BXfOfsIjl7RJYrv7hzRc4Y6p ++vCasKHS0Tcz2+H8RiRui2CRECiIsP3sNVJUqacIUXeUUAC9QoyZGKAL/2ctSJpg0b9PRWt6 FMSnjBHV6U5vmwc31n/KBRC7hfORDSx9YCHtOGWgPnaNNZYpz9XD+vvcHfcK7myzjARDJXOFJ U6YoWu7FdajwzxI9fGh9N4c9o4Ykr5mbpSl3E/CN+9+wu9Y3XIhxAGg+VfH/Nipy9gMnkmYRD 1DQZdL8LwOFOQsz0tr83E8uOFqc8i+rM97rfUl6Ikxg== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 75170 Cc: Eli Zaretskii <eliz@HIDDEN>, 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Roland Winkler <winkler@HIDDEN> writes: > 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)? We indeed recommend using (setf (alist-get ...)), IIUC this is _exactly_ what you were looking for. Your patch contains an implementation of the setter of `alist-get', and we would add a duplication. If you did not find this thing, maybe we need to add a hint to some chapter of the manual? Michael.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 18 Jan 2025 09:33:43 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 18 04:33:43 2025 Received: from localhost ([127.0.0.1]:40201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tZ5D5-0001dI-2X for submit <at> debbugs.gnu.org; Sat, 18 Jan 2025 04:33:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43206) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tZ5D2-0001d4-DQ for 75170 <at> debbugs.gnu.org; Sat, 18 Jan 2025 04:33:40 -0500 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 <eliz@HIDDEN>) id 1tZ5Cv-000484-7c; Sat, 18 Jan 2025 04:33:33 -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=rK2Dr16jCorUjxGO8r8KZh3pbbhevPdurZUpTO8ZqY8=; b=On3E3NElOkR9 epHjq36SrDqW6ZE+PVNA3Y8k10RkCVThLcpl3wiFQZku2a9r0WHUPhWq+eJzd9I7+JSS8RsRA6RNV VSgcyH91OvtJ6q2dIZ7HCcQbjUH9CK0orHimfy57wFWnARgMak0J92Xa9cyylKN29PcZF8z2IAaxT PosqekRx2S45Nndn+uo5ud6lY36IpT1hWk0qVTfbvwZdHYKmjpkupIj/UrPnVYGUpbQ7+P/XWhLJ8 Pr40HSjhtAUxY4clHi4NEwXL8T0nI3nKUhsR7r3gLqNMVgwxNeJ2EVau3nUQgULtB4C2aq9CjbXvX 0Qq6K3KD5T79EgCEGOxBmg==; Date: Sat, 18 Jan 2025 11:33:28 +0200 Message-Id: <86sepgbh5j.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: stefankangas@HIDDEN, acorallo@HIDDEN In-Reply-To: <86wmf970df.fsf@HIDDEN> (message from Eli Zaretskii on Sun, 05 Jan 2025 17:21:00 +0200) Subject: Re: bug#75170: add-to-alist: new function References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> <86wmf970df.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org, winkler@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Ping! > Cc: 75170 <at> debbugs.gnu.org > Date: Sun, 05 Jan 2025 17:21:00 +0200 > From: Eli Zaretskii <eliz@HIDDEN> > > > From: Roland Winkler <winkler@HIDDEN> > > Cc: 75170 <at> 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? > > > >
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 5 Jan 2025 15:21:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 05 10:21:10 2025 Received: from localhost ([127.0.0.1]:34838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tUSRB-0000y1-IG for submit <at> debbugs.gnu.org; Sun, 05 Jan 2025 10:21:09 -0500 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 <eliz@HIDDEN>) id 1tUSRA-0000xp-23 for 75170 <at> debbugs.gnu.org; Sun, 05 Jan 2025 10:21:08 -0500 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 <eliz@HIDDEN>) 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==; Date: Sun, 05 Jan 2025 17:21:00 +0200 Message-Id: <86wmf970df.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Roland Winkler <winkler@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>, Andrea Corallo <acorallo@HIDDEN> In-Reply-To: <87zfkelf11.fsf@HIDDEN> (message from Roland Winkler on Sun, 29 Dec 2024 08:50:18 -0600) Subject: Re: bug#75170: add-to-alist: new function References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> <87zfkelf11.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Roland Winkler <winkler@HIDDEN> > Cc: 75170 <at> 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?
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 29 Dec 2024 14:54:26 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 29 09:54:26 2024 Received: from localhost ([127.0.0.1]:54341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tRugU-0003qo-2Q for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 09:54:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tRugS-0003qZ-32 for 75170 <at> debbugs.gnu.org; Sun, 29 Dec 2024 09:54:24 -0500 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 <winkler@HIDDEN>) id 1tRugL-0004Xm-5s; Sun, 29 Dec 2024 09:54:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=xgO5suy9RsPH5YXpRYbnBamYcyP3IH+aQvLEE4oYZMU=; b=hbqbIx/ErxH9E5ytKKkw v2BxKzPRWriAAHLJJjqIGfcA81uMv/IyYjMLUHwUR8aUkE7WZMMgud4PLirrGlAoc7ClDqGWjv2C0 vWn1os9YOW68T17oQWQB5B4++4UHg00cR9oAhDr6vVuLztckmt8LGL9ObuxVii9NZgF3JnR3lJchg VGGCwaU/860NlWgfClcLvnxFPBEMjVGvO9apio9MuPuGBYJanyc1x6fhSEXEkxvjSObsFfGBvWaaN ka5S6nZX07+cEIyWb54BeReHOyaVvqh6liWcme+fOFHKRcVh8SogYiPkC1TG2lrQ+TIxcSgNHFmvy 6zIEYRsNPb38zQ==; From: Roland Winkler <winkler@HIDDEN> To: Juri Linkov <juri@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <87h66m3ox1.fsf@HIDDEN> (Juri Linkov's message of "Sun, 29 Dec 2024 09:54:02 +0200") References: <878qrzm4sb.fsf@HIDDEN> <874j2nm1zn.fsf@HIDDEN> <87h66m3ox1.fsf@HIDDEN> Date: Sun, 29 Dec 2024 08:54:14 -0600 Message-ID: <87v7v2leuh.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Sun, Dec 29 2024, Juri Linkov wrote: > Also there are threads discussing 'org--tag-add-to-alist' and > 'package--append-to-alist' (renamed from 'package--add-to-alist'). My understanding of these functions is that they serve rather different purposes. They are not intended to be used in user init files.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 29 Dec 2024 14:50:28 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 29 09:50:28 2024 Received: from localhost ([127.0.0.1]:54329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tRuce-0003kI-0X for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 09:50:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tRucb-0003jr-Tp for 75170 <at> debbugs.gnu.org; Sun, 29 Dec 2024 09:50:26 -0500 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 <winkler@HIDDEN>) id 1tRucW-00043W-Me for 75170 <at> debbugs.gnu.org; Sun, 29 Dec 2024 09:50:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=LDa1wVBpKOVjTYaVnHqhFtkG5t1mSjTz9ywnxNarvFo=; b=Vd95aIHPNa/5YgcKPr58 QlIRiRUku1AP83qbeUoc9QKuau8rgbgRoSqXlE3y0j3c6/Y8WMHbnXEshNdm9JdMeFVJ4j6VwSMhO dOD7/+pZFPBWx4u6XGJeYuQ1VnYwE+uCcLfyKsv5K7/yOfhpD/ZZlYgZGF0jV0k9UNIRNLaBHwqJV zolSJxgSLEz/iwCak0HpBrfxLAAnrYnrOGuG073dzAPKL2+TindRBjgUUGA1ZqgH4a2OvdQhMhBDs gCsEULMVhVbnzMtcV9d2243BvUhoG1mgfGyxBqHCecTTHlN/LCD5HJr2MCOPsws2fI1q3U7Pj3zHd sHaIl5mMO2j+WA==; From: Roland Winkler <winkler@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <86cyhbq66r.fsf@HIDDEN> (Eli Zaretskii's message of "Sun, 29 Dec 2024 09:50:04 +0200") References: <878qrzm4sb.fsf@HIDDEN> <86cyhbq66r.fsf@HIDDEN> Date: Sun, 29 Dec 2024 08:50:18 -0600 Message-ID: <87zfkelf11.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) 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?
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 29 Dec 2024 07:59:09 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 29 02:59:09 2024 Received: from localhost ([127.0.0.1]:53644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tRoCa-0000nH-Kb for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 02:59:08 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:55083) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1tRoCY-0000mk-0X for 75170 <at> debbugs.gnu.org; Sun, 29 Dec 2024 02:59:06 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 7C82340002; Sun, 29 Dec 2024 07:58:36 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <874j2nm1zn.fsf@HIDDEN> (Roland Winkler's message of "Sun, 29 Dec 2024 00:34:20 -0600") Organization: LINKOV.NET References: <878qrzm4sb.fsf@HIDDEN> <874j2nm1zn.fsf@HIDDEN> Date: Sun, 29 Dec 2024 09:54:02 +0200 Message-ID: <87h66m3ox1.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) >>> Here's a handy function I'd like to see added to Emacs 21: >>> add-to-alist. > > I forgot to say: I could not find any follow-up or discussion of > Stephen's proposal > > https://lists.gnu.org/archive/html/bug-gnu-emacs/2001-02/msg00066.html > > I know about the very different approaches underlying the function > add-to-list compared to the macro pushnew. I followed the design of > add-to-list as I am thinking (like Stephen) of similar use cases. While indeed there were no responses to the original message, other proposed implementations can be found as well, e.g. https://lists.gnu.org/archive/html/bug-gnu-emacs/2002-04/msg00669.html https://lists.gnu.org/archive/html/bug-gnu-emacs/2002-04/msg00671.html Also there are threads discussing 'org--tag-add-to-alist' and 'package--append-to-alist' (renamed from 'package--add-to-alist').
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 29 Dec 2024 07:50:15 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 29 02:50:14 2024 Received: from localhost ([127.0.0.1]:53637 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tRo3y-0000T2-GA for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 02:50:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tRo3w-0000Q2-0C for 75170 <at> debbugs.gnu.org; Sun, 29 Dec 2024 02:50:12 -0500 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 <eliz@HIDDEN>) id 1tRo3q-0006ih-IA for 75170 <at> debbugs.gnu.org; Sun, 29 Dec 2024 02:50:06 -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=ZZQGGx/Y0r1PegjkG/cNejJ5wVf22mUdBRIYM0gaRBk=; b=CGrE+eaApweK msVoGffc7x9GG+lCMAuR3KyJMtMl1WsLA0rrPeyUcZi4IFOOTwDgZOy2bjPxiJYGUIwPkKu49UhaH X9a6VWxg1kWCj3/jC7EISDsbVlWinss4HsrXaU6kZtcRaylRZhDYdHAtvCJzwxHB6UEUjtUiKlJX4 jFK0IJI7KOIFEjVE76RwHfXGUORCyekdKhvrq3ESyykkre65zJPV0xMuUprl37JRY0DSgcdm4YD/p O19f8ZqLzK4DNHEn3TmNntEwUSp51HjqpbBeXblJJILRwICfWssbznwwOMF9nH0xxg7J85sub1pnB 3pUJDoHUwLtCwnTCgTAXzw==; Date: Sun, 29 Dec 2024 09:50:04 +0200 Message-Id: <86cyhbq66r.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Roland Winkler <winkler@HIDDEN> In-Reply-To: <878qrzm4sb.fsf@HIDDEN> (message from Roland Winkler on Sat, 28 Dec 2024 23:33:56 -0600) Subject: Re: bug#75170: add-to-alist: new function References: <878qrzm4sb.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Roland Winkler <winkler@HIDDEN> > Date: Sat, 28 Dec 2024 23:33:56 -0600 > > On Mon, 12 Feb 2001, Stephen Gildea wrote: > > Here's a handy function I'd like to see added to Emacs 21: add-to-alist. > > It is like add-to-list, but it looks only at the cars of the element to > > be added and the existing list elements when considering a match. An > > additional optional argument to add-to-alist says what to do if the car > > matches but the cdr does not. > > > > I use this function in my .emacs to update values in alists such as > > default-frame-alist and auto-mode-alist; I'm sure it has other uses. > > My goal in proposing this function is to allow .emacs files to be > > shorter and easier to write. The functions add-to-list and add-hook > > were important steps in that direction; here is another such step. > > > > > > (defun add-to-alist (alist-var elt-cons &optional no-replace) > > "Add to the value of ALIST-VAR an element ELT-CONS if it isn't there yet. > > If an element with the same car as the car of ELT-CONS is already present, > > replace it with ELT-CONS unless NO-REPLACE is non-nil; if a matching > > element is not already present, add ELT-CONS to the front of the alist. > > The test for presence of the car of ELT-CONS is done with `equal'." > > (let ((existing-element (assoc (car elt-cons) (symbol-value alist-var)))) > > (if existing-element > > (or no-replace > > (rplacd existing-element (cdr elt-cons))) > > (set alist-var (cons elt-cons (symbol-value alist-var)))))) > > > > > > The no-replace argument is useful for setting auto-mode-alist when you > > don't know whether Emacs supports a particular programming language. > > For example, the following suppresses using text-mode for m4 files in > > Emacs 19 but doesn't override using m4-mode in Emacs 20. > > > > (setq default-major-mode 'text-mode) > > (add-to-alist 'auto-mode-alist '("\\.m4\\'" . fundamental-mode) t) > > While I thought about a function add-to-alist I found the above thread > from 24 years ago. Stephen's message describes nicely when such a > function can be useful. I suggest to add such a function to subr.el. > > The code below follows the conventions of add-to-list. > > (defun add-to-alist (alist-var elt-cons &optional no-replace append compare-fn) > "Add ELT-CONS to the value of ALIST-VAR if it isn't there yet. > If an element with the same car as the car of ELT-CONS is already present > in ALIST-VAR, replace it with ELT-CONS unless NO-REPLACE is non-nil. > If a matching element is not yet present, add ELT-CONS at the beginning > of ALIST-VAR. If APPEND is non-nil, add ELT-CONS at the end of ALIST-VAR. > The test for presence of ELT-CONS is done with `equal', or with COMPARE-FN > if that's non-nil. > ALIST-VAR should not refer to a lexical variable. Thanks. 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?
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at 75170) by debbugs.gnu.org; 29 Dec 2024 07:33:11 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 29 02:33:11 2024 Received: from localhost ([127.0.0.1]:53617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tRnnS-00084N-N5 for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 02:33:11 -0500 Received: from mail.eshelyaron.com ([107.175.124.16]:55818 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <me@HIDDEN>) id 1tRnnQ-000848-Gq for 75170 <at> debbugs.gnu.org; Sun, 29 Dec 2024 02:33:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1735457588; bh=MJRKQcu3KampE4f/hQoHEtx6jLtAoIWotqV7LJYRZt4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=PEaBYoayLVsogaq7+ylxDM/Ao0kDIl0uyxbKZlkN5BvlrCdYs4StO2zsYPrdazPUx ksa4Mnn2TXsKblu8FdTTLNUFSGvjiVh3N/QSvIY8QSF9VQHoLXk8mqNkNyIXCZnXIl /BigwDNyW9Pn9KFKr+6fsMxJ0XgDhgKiTy3lz6/kZFOH4XI804V7vG1jxLVZ0Ik6Y6 2lRP8UnPDEZyJ+/B4rJlpnGicrRJReDAWHDspV874t4o6/+PmqhmFVh678zgi4cLyT ao8LNQDMhV4n16sIfQWeFKIa5RFt1xD+G6g70JXDzWQQOUJD5Z8U/bVt4wDsrY4USI qekjUh3PNro3g== From: Eshel Yaron <me@HIDDEN> To: Roland Winkler <winkler@HIDDEN> Subject: Re: bug#75170: add-to-alist: new function In-Reply-To: <878qrzm4sb.fsf@HIDDEN> (Roland Winkler's message of "Sat, 28 Dec 2024 23:33:56 -0600") References: <878qrzm4sb.fsf@HIDDEN> X-Hashcash: 1:20:241229:winkler@HIDDEN::Kf76vHcV8XLKx52l:1k5s X-Hashcash: 1:20:241229:75170 <at> debbugs.gnu.org::rw+OTBiUW4G9jZkI:2VHG Date: Sun, 29 Dec 2024 08:33:06 +0100 Message-ID: <m1y0zzlz9p.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75170 Cc: 75170 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Roland Winkler <winkler@HIDDEN> writes: > On Mon, 12 Feb 2001, Stephen Gildea wrote: [...] > While I thought about a function add-to-alist I found the above thread > from 24 years ago. Stephen's message describes nicely when such a > function can be useful. I suggest to add such a function to subr.el. > > The code below follows the conventions of add-to-list. > > (defun add-to-alist (alist-var elt-cons &optional no-replace append compare-fn) > "Add ELT-CONS to the value of ALIST-VAR if it isn't there yet. > If an element with the same car as the car of ELT-CONS is already present > in ALIST-VAR, replace it with ELT-CONS unless NO-REPLACE is non-nil. > If a matching element is not yet present, add ELT-CONS at the beginning > of ALIST-VAR. If APPEND is non-nil, add ELT-CONS at the end of ALIST-VAR. > The test for presence of ELT-CONS is done with `equal', or with COMPARE-FN > if that's non-nil. > ALIST-VAR should not refer to a lexical variable. > > The return value is the new value of ALIST-VAR." > (let ((elt (cond ((or (null compare-fn) (eq compare-fn #'equal)) > (assoc (car elt-cons) (symbol-value alist-var))) > ((eq compare-fn #'eq) > (assq (car elt-cons) (symbol-value alist-var))) > (t > (let ((alist (symbol-value alist-var)) > (key (car elt-cons))) > (while (and alist > (not (funcall compare-fn key (caar alist)))) > (setq alist (cdr alist))) > (car alist)))))) > (if elt > (progn > (unless no-replace > (setcdr elt (cdr elt-cons))) > (symbol-value alist-var)) > (set alist-var > (if append > (append (symbol-value alist-var) (list elt-cons)) > (cons elt-cons (symbol-value alist-var))))))) FWIW, in my working branch I use alist-set which does something similar, I think: --8<---------------cut here---------------start------------->8--- (defun alist-set (key alist value &optional testfn) "Associate VALUE with KEY in ALIST, comparing keys with TESTFN." (setf (alist-get key alist nil nil testfn) value)) --8<---------------cut here---------------end--------------->8--- Cheers, Eshel
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 29 Dec 2024 06:34:26 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 29 01:34:26 2024 Received: from localhost ([127.0.0.1]:53520 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tRmsc-0004zN-4R for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 01:34:26 -0500 Received: from lists.gnu.org ([209.51.188.17]:50142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tRmsZ-0004zE-Ku for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 01:34:25 -0500 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 <winkler@HIDDEN>) id 1tRmsY-0004Ld-N0 for bug-gnu-emacs@HIDDEN; Sun, 29 Dec 2024 01:34:23 -0500 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 <winkler@HIDDEN>) id 1tRmsY-0007zt-Ex for bug-gnu-emacs@HIDDEN; Sun, 29 Dec 2024 01:34:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=n+WTWopX1skhaMAwezbYHD8CgMSYo2Ov79yN2BObDUI=; b=jomJw320dE+0l4YzxAHp suSkPlPljoy0XwDVskzBZ/ce+5pqpe9808OZPYHC6szEeLsmCrqVtht1cG1GEN99OOREraf95Xt9i NX9nIPhreoIeakoLnqdNj4j7aNcYeNFOv5/np+o/h5E87yleYFM61PcjfzZ/1NYGCB/Xn8kw3LxJs nzYShu0GyI99+adMKDD4fxjSkXwn7JfmTl3zwId4EnBmeObbA6eIvZ6+u2UjUb8+OkulWhTb9Rh69 zaNAlBkUaph1HvFDiFkJ/+E7wK3OHlgd5cqJA/pML+RDqPveDv6/z+qI4x2RKj7GItaWHDeEv+C2u floI9ahnlz8REw==; From: Roland Winkler <winkler@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: Re: add-to-alist: new function In-Reply-To: <878qrzm4sb.fsf@HIDDEN> (Roland Winkler's message of "Sat, 28 Dec 2024 23:33:56 -0600") References: <878qrzm4sb.fsf@HIDDEN> Date: Sun, 29 Dec 2024 00:34:20 -0600 Message-ID: <874j2nm1zn.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Sat, Dec 28 2024, Roland Winkler wrote: > On Mon, 12 Feb 2001, Stephen Gildea wrote: >> Here's a handy function I'd like to see added to Emacs 21: >> add-to-alist. I forgot to say: I could not find any follow-up or discussion of Stephen's proposal https://lists.gnu.org/archive/html/bug-gnu-emacs/2001-02/msg00066.html I know about the very different approaches underlying the function add-to-list compared to the macro pushnew. I followed the design of add-to-list as I am thinking (like Stephen) of similar use cases.
bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 29 Dec 2024 05:34:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 29 00:34:08 2024 Received: from localhost ([127.0.0.1]:53463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tRlwF-0001nD-Oj for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 00:34:08 -0500 Received: from lists.gnu.org ([209.51.188.17]:35900) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <winkler@HIDDEN>) id 1tRlwD-0001n3-FV for submit <at> debbugs.gnu.org; Sun, 29 Dec 2024 00:34:05 -0500 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 <winkler@HIDDEN>) id 1tRlwC-0003Zn-LR for bug-gnu-emacs@HIDDEN; Sun, 29 Dec 2024 00:34:04 -0500 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 <winkler@HIDDEN>) id 1tRlwC-0003Hh-7K for bug-gnu-emacs@HIDDEN; Sun, 29 Dec 2024 00:34:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=t1mkyvGNBr0B1s1A4AmENN7//+icAfreDWlg1cNx7Js=; b=pVjH/oGgC9MBDd 3ci7q7ka+4n9bmJi1p4ydW90d4GOU8vDHN2A98IDIzQEsKCm84e3B0lAMB19dqJ93whf+awNJI3Uv RrHUjTxTaj/QqzPZDxcqpvlvu7DCjY4eD0YzNT59cMxvEKiv9/nflsth/0W9n2jPHIcjGu274bfJQ K8qIwrd1bNXkzJ2gYJtGhlcvoPIq22BKiNwKyfgkCIGhvlrHoddqnZ2i1/E+4QmGXulE087Dghjen DkCU5x0A2uvjnc0OT/kGgzMYavHT+rDg2TOLl/CCGITTpZ8a/Z7RvkR86rswmUkcToY3EHvtoPGRp HcLp8lcox2M/1zbAPw0w==; From: Roland Winkler <winkler@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: Re: add-to-alist: new function Date: Sat, 28 Dec 2024 23:33:56 -0600 Message-ID: <878qrzm4sb.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) On Mon, 12 Feb 2001, Stephen Gildea wrote: > Here's a handy function I'd like to see added to Emacs 21: add-to-alist. > It is like add-to-list, but it looks only at the cars of the element to > be added and the existing list elements when considering a match. An > additional optional argument to add-to-alist says what to do if the car > matches but the cdr does not. > > I use this function in my .emacs to update values in alists such as > default-frame-alist and auto-mode-alist; I'm sure it has other uses. > My goal in proposing this function is to allow .emacs files to be > shorter and easier to write. The functions add-to-list and add-hook > were important steps in that direction; here is another such step. > > > (defun add-to-alist (alist-var elt-cons &optional no-replace) > "Add to the value of ALIST-VAR an element ELT-CONS if it isn't there yet. > If an element with the same car as the car of ELT-CONS is already present, > replace it with ELT-CONS unless NO-REPLACE is non-nil; if a matching > element is not already present, add ELT-CONS to the front of the alist. > The test for presence of the car of ELT-CONS is done with `equal'." > (let ((existing-element (assoc (car elt-cons) (symbol-value alist-var)))) > (if existing-element > (or no-replace > (rplacd existing-element (cdr elt-cons))) > (set alist-var (cons elt-cons (symbol-value alist-var)))))) > > > The no-replace argument is useful for setting auto-mode-alist when you > don't know whether Emacs supports a particular programming language. > For example, the following suppresses using text-mode for m4 files in > Emacs 19 but doesn't override using m4-mode in Emacs 20. > > (setq default-major-mode 'text-mode) > (add-to-alist 'auto-mode-alist '("\\.m4\\'" . fundamental-mode) t) While I thought about a function add-to-alist I found the above thread from 24 years ago. Stephen's message describes nicely when such a function can be useful. I suggest to add such a function to subr.el. The code below follows the conventions of add-to-list. (defun add-to-alist (alist-var elt-cons &optional no-replace append compare-fn) "Add ELT-CONS to the value of ALIST-VAR if it isn't there yet. If an element with the same car as the car of ELT-CONS is already present in ALIST-VAR, replace it with ELT-CONS unless NO-REPLACE is non-nil. If a matching element is not yet present, add ELT-CONS at the beginning of ALIST-VAR. If APPEND is non-nil, add ELT-CONS at the end of ALIST-VAR. The test for presence of ELT-CONS is done with `equal', or with COMPARE-FN if that's non-nil. ALIST-VAR should not refer to a lexical variable. The return value is the new value of ALIST-VAR." (let ((elt (cond ((or (null compare-fn) (eq compare-fn #'equal)) (assoc (car elt-cons) (symbol-value alist-var))) ((eq compare-fn #'eq) (assq (car elt-cons) (symbol-value alist-var))) (t (let ((alist (symbol-value alist-var)) (key (car elt-cons))) (while (and alist (not (funcall compare-fn key (caar alist)))) (setq alist (cdr alist))) (car alist)))))) (if elt (progn (unless no-replace (setcdr elt (cdr elt-cons))) (symbol-value alist-var)) (set alist-var (if append (append (symbol-value alist-var) (list elt-cons)) (cons elt-cons (symbol-value alist-var)))))))
Roland Winkler <winkler@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#75170
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.