GNU bug report logs - #34708
alist-get has unclear documentation

Previous Next

Package: emacs;

Reported by: "Miguel V. S. Frasson" <mvsfrasson <at> gmail.com>

Date: Sat, 2 Mar 2019 04:52:01 UTC

Severity: minor

Done: Michael Heerdegen <michael_heerdegen <at> web.de>

Bug is archived. No further changes may be made.

Full log


Message #130 received at 34708 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: "Miguel V. S. Frasson" <mvsfrasson <at> gmail.com>
Cc: 34708 <at> debbugs.gnu.org
Subject: Re: bug#34708: Thanks
Date: Fri, 19 Apr 2019 06:18:11 +0200
"Miguel V. S. Frasson" <mvsfrasson <at> gmail.com> 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.




This bug report was last modified 6 years and 32 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.