unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35206: [PATCH] Misleading `list-get' argument description
@ 2019-04-09 10:34 Mattias Engdegård
  2019-04-09 11:00 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Mattias Engdegård @ 2019-04-09 10:34 UTC (permalink / raw)
  To: 35206

[-- Attachment #1: Type: text/plain, Size: 320 bytes --]

The doc string for `list-get' says

  Use TESTFN to lookup in the alist if non-nil.  Otherwise, use `assq'.

which is misleading since it's an equality predicate, not a look-up function, and the default is `eq', not `assq'.
How about changing it to

  Equality is defined by TESTFN or by `eq' if nil or omitted.

[-- Attachment #2: 0001-Clarify-the-TESTFN-argument-to-alist-get.patch --]
[-- Type: application/octet-stream, Size: 1088 bytes --]

From 0bdfa84e6c55ff97286818b42ed3e6f035d47151 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Tue, 9 Apr 2019 12:27:30 +0200
Subject: [PATCH] Clarify the TESTFN argument to `alist-get'

* lisp/subr.el (alist-get): Clarify the meaning of the TESTFN argument.
It's an equality predicate, not a look-up function.
---
 lisp/subr.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 45b3916196..5eb6a53f78 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -781,7 +781,7 @@ Elements of ALIST that are not conses are ignored."
 (defun alist-get (key alist &optional default remove testfn)
   "Return the value associated with KEY in ALIST.
 If KEY is not found in ALIST, return DEFAULT.
-Use TESTFN to lookup in the alist if non-nil.  Otherwise, use `assq'.
+Equality is defined by TESTFN or by `eq' if nil or omitted.
 
 You can use `alist-get' in PLACE expressions.  This will modify
 an existing association (more precisely, the first one if
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-09 14:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-09 10:34 bug#35206: [PATCH] Misleading `list-get' argument description Mattias Engdegård
2019-04-09 11:00 ` Eli Zaretskii
2019-04-09 11:26   ` Mattias Engdegård
2019-04-09 11:45     ` Mattias Engdegård
2019-04-09 14:41       ` Eli Zaretskii
2019-04-09 14:59         ` Mattias Engdegård

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).