[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 19 Apr 2019 06:18:11 +0200
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
"Miguel V. S. Frasson" <address@hidden> 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).
(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.
- bug#34708: Thanks, Miguel V. S. Frasson, 2019/04/18
- bug#34708: Thanks,
Michael Heerdegen <=