Subject: Re: bug#27584: 26.0.50; alist-get: Add optional arg TESTFN

From: Nicolas Petton <[email-masked]>
Date: Wed, 05 Jul 2017 11:19:20 +0200

Tino Calancha <[email-masked]> 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