Subject: bug#34708: Thanks

From: Michael Heerdegen <[email-masked]>
Date: Fri, 19 Apr 2019 06:18:11 +0200

"Miguel V. S. Frasson" <[email-masked]> writes:

> I learned a from this discussion, specially about how to use
> alist-get. The only missing lesson was how to remove association of a
> key from alist using setf and alist-get.
>
> Could someone give a quick example?

The modified docstring of alist-get has now an example.  It says:

[...]
When using it to set a value, optional argument REMOVE non-nil
means to remove KEY from ALIST if the new value is `eql' to
DEFAULT (more precisely the first found association will be
deleted from the alist).

Example:

  (setq foo '((a . 1) (b . 2)))
  (setf (alist-get 'b foo nil 'remove) nil)

  foo => ((a . 1))

Does this suffice?

BTW, it doesn't say you have to use this feature.  If you find it
confusing, use delq+assoc+setq, or alternatively, what map.el provides.

Regards,

Michael.