From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.bugs Subject: bug#27584: 26.0.50; alist-get: Add optional arg TESTFN Date: Wed, 05 Jul 2017 11:19:20 +0200 Message-ID: <87mv8j6y1z.fsf@petton.fr> References: <87tw2rva7v.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1499246415 28147 195.159.176.226 (5 Jul 2017 09:20:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Jul 2017 09:20:15 +0000 (UTC) Cc: stefan monnier To: Tino Calancha , 27584@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 05 11:20:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSgTh-0006sd-5k for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Jul 2017 11:20:09 +0200 Original-Received: from localhost ([::1]:45025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSgTl-0000Un-1O for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Jul 2017 05:20:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSgTe-0000T3-V1 for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 05:20:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSgTa-0006Kn-W0 for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 05:20:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50285) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSgTa-0006KQ-Ok for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 05:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dSgTa-0007mq-Ch for bug-gnu-emacs@gnu.org; Wed, 05 Jul 2017 05:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Nicolas Petton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jul 2017 09:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27584 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27584-submit@debbugs.gnu.org id=B27584.149924637329893 (code B ref 27584); Wed, 05 Jul 2017 09:20:02 +0000 Original-Received: (at 27584) by debbugs.gnu.org; 5 Jul 2017 09:19:33 +0000 Original-Received: from localhost ([127.0.0.1]:52962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSgT7-0007m5-DC for submit@debbugs.gnu.org; Wed, 05 Jul 2017 05:19:33 -0400 Original-Received: from petton.fr ([89.234.186.68]:52610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSgT6-0007lr-0e for 27584@debbugs.gnu.org; Wed, 05 Jul 2017 05:19:32 -0400 In-Reply-To: <87tw2rva7v.fsf@calancha-pc> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=petton.fr; s=mail; t=1499246364; bh=LYiXoxqBkWxMgqQjJPnxNFJWYoJeWz9MbLRQnUeOH6s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:MIME-Version:Content-Type; b=aoExXphRZ34PLHLCCcQlxMvGocQjIQpAAZ95gUIz5DiDviTXvM7WZsoTvpp5KlHG1FK+oUtth1fvxhYlGh90RSM/rakSMduGV6F3T0BLr77wkVdy22ug0UOIBg7xXKaYBa2pTAaxY6MxCv6gwQYIRTUFpbbjlDrCCL6MBuEHUCU= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134202 Archived-At: --=-=-= Content-Type: text/plain Tino Calancha writes: > Consider the following question: > https://emacs.stackexchange.com/questions/33892/replace-element-of-alist-using-equal-even-if-key-does-not-exist/33893#33893 > > 1. The OP wants to update an alist without adding duplicates, > 2. but he doesn't want to restrict the lookup in the alist to 'eq'. > > The OP realized that > > (setf (alist-get key alist) val) > > is not an option because, `alist-get' assumes 'eq' in the lookup. > Then he writes his own function: > ;; docstrig omitted: > (defun alist-set (key val alist &optional symbol) > (if-let ((pair (if symbol (assq key alist) (assoc key alist)))) > (setcdr pair val) > (push (cons key val) alist)) > alist) > > * In the same thread, Drew suggests to add an optional arg TESTFN in `alist-get'. > * We might also tweak `map.el' so that the following code works: Thanks, I like your changes. If this is going to be installed, could you add tests to map-tests.el as well? Cheers, Nico --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJZXK8YAAoJECM1h6R8IHkQwMAIAL0twb87AKaW7rd+7u3TM7B0 AhEgjvJgYLUpCbJFGDPUViqzSyHkWvPtI4frpW3zyaPSzQ5tGOK4ZUF+W2dPGIFs OmuR5B1+SogMoYkOdL8vHsN8wLClyzDOeuPyngzR24H/D++5wYAaYe5XKVKiYs5b FRO26paBBaAaEWz1Kg+TQ2/t5ziRyf1WfXNvJ3ajOHYXX8k3/SWdNkKfc5BLkZkX Z5VIKtO5xLW7xtOG6UtUTNutPYoMJOcRD3Vham8q4RSfCMNIDctt8M1Rf5hcMBrM YK2IO2/LAc5ZvqEpEnb6SNJlRCQiTCqzLrDUWJdfZ7joweKdf4F0lZsMUISRPRM= =8STH -----END PGP SIGNATURE----- --=-=-=--