diff options
| author | Tino Calancha | 2017-07-17 21:30:50 +0900 |
|---|---|---|
| committer | Tino Calancha | 2017-07-17 21:30:50 +0900 |
| commit | 76e1f7d00fbff7bf8183ba85db2f67a11aa2d5ce (patch) | |
| tree | ac3d9fbe5fa46dbad70b527355e2f1ba997f36f8 /doc | |
| parent | 4968aa685b85840d79258ff6b61ba2bcfb99e2bc (diff) | |
| download | emacs-76e1f7d00fbff7bf8183ba85db2f67a11aa2d5ce.tar.gz emacs-76e1f7d00fbff7bf8183ba85db2f67a11aa2d5ce.zip | |
alist-get: Add optional arg TESTFN
If TESTFN is non-nil, then it is the predicate to lookup
the alist. Otherwise, use 'eq' (Bug#27584).
* lisp/subr.el (alist-get): Add optional arg FULL.
* lisp/emacs-lisp/map.el (map-elt, map-put): Add optional arg TESTFN.
* lisp/emacs-lisp/gv.el (alist-get): Update expander.
* doc/lispref/lists.texi (Association Lists): Update manual.
* etc/NEWS: Announce the changes.
* test/lisp/emacs-lisp/map-tests.el (test-map-put-testfn-alist)
(test-map-elt-testfn): New tests.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/lists.texi | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index 966d8f18b17..0c993806824 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi | |||
| @@ -1589,16 +1589,20 @@ keys may not be symbols: | |||
| 1589 | @end smallexample | 1589 | @end smallexample |
| 1590 | @end defun | 1590 | @end defun |
| 1591 | 1591 | ||
| 1592 | @defun alist-get key alist &optional default remove | 1592 | @defun alist-get key alist &optional default remove testfn |
| 1593 | This function is like @code{assq}, but instead of returning the entire | 1593 | This function is similar to @code{assq}. It finds the first |
| 1594 | association for @var{key} in @var{alist}, | 1594 | association @w{@code{(@var{key} . @var{value})}} by comparing |
| 1595 | @w{@code{(@var{key} . @var{value})}}, it returns just the @var{value}. | 1595 | @var{key} with @var{alist} elements, and, if found, returns the |
| 1596 | If @var{key} is not found in @var{alist}, it returns @var{default}. | 1596 | @var{value} of that association. If no association is found, the |
| 1597 | 1597 | function returns @var{default}. Comparison of @var{key} against | |
| 1598 | This is a generalized variable (@pxref{Generalized Variables}) that | 1598 | @var{alist} elements uses the function specified by @var{testfn}, |
| 1599 | can be used to change a value with @code{setf}. When using it to set | 1599 | defaulting to @code{eq}. |
| 1600 | a value, optional argument @var{remove} non-@code{nil} means to remove | 1600 | |
| 1601 | @var{key} from @var{alist} if the new value is @code{eql} to @var{default}. | 1601 | This is a generalized variable (@pxref{Generalized Variables}) |
| 1602 | that can be used to change a value with @code{setf}. When | ||
| 1603 | using it to set a value, optional argument @var{remove} non-@code{nil} | ||
| 1604 | means to remove @var{key}'s association from @var{alist} if the new | ||
| 1605 | value is @code{eql} to @var{default}. | ||
| 1602 | @end defun | 1606 | @end defun |
| 1603 | 1607 | ||
| 1604 | @defun rassq value alist | 1608 | @defun rassq value alist |