aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Petton2015-09-13 16:18:24 +0200
committerNicolas Petton2015-09-21 11:48:55 +0200
commit0a893f0cfa166d7f17d982c3f0503dff2be25f62 (patch)
treecdb172d4889e26e5502fee4dbbe5f3af1d5ebc57
parente2f0dd2f49d8638d20615bfa38e95a71202dd543 (diff)
downloademacs-0a893f0cfa166d7f17d982c3f0503dff2be25f62.tar.gz
emacs-0a893f0cfa166d7f17d982c3f0503dff2be25f62.zip
Better docstring and parameter name for seq-find
* lisp/emacs-lisp/seq.el (seq-find): Improve the docstring and rename the parameter `sentinel' to `default'. * doc/lispref/sequences.texi (Sequence Functions): Update the documentation for `seq-find' accordingly.
-rw-r--r--doc/lispref/sequences.texi9
-rw-r--r--lisp/emacs-lisp/seq.el12
2 files changed, 10 insertions, 11 deletions
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index 6292c02a21d..b85d5d4c1b1 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -578,15 +578,14 @@ value is the value returned by @var{predicate}.
578@end example 578@end example
579@end defun 579@end defun
580 580
581@defun seq-find predicate sequence &optional sentinel 581@defun seq-find predicate sequence &optional default
582 This function returns the first element for which @var{predicate} 582 This function returns the first element for which @var{predicate}
583returns non-@code{nil} in @var{sequence}. If no element matches 583returns non-@code{nil} in @var{sequence}. If no element matches
584@var{predicate}, @var{sentinel} is returned if non-@code{nil}, 584@var{predicate}, @var{default} is returned.
585@code{nil} otherwise.
586 585
587Note that this function has an ambiguity if the found element is 586Note that this function has an ambiguity if the found element is
588@code{nil}, and if no @var{sentinel} is specified, as it cannot be 587identical to @var{default}, as it cannot be known if an element was
589known if an element was found or not. 588found or not.
590 589
591@example 590@example
592@group 591@group
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 4b50a0a9b7b..e0f17c0335d 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -270,18 +270,18 @@ If so, return the non-nil value returned by PRED."
270 (throw 'seq--break result)))) 270 (throw 'seq--break result))))
271 nil)) 271 nil))
272 272
273(cl-defgeneric seq-find (pred seq &optional sentinel) 273(cl-defgeneric seq-find (pred seq &optional default)
274 "Return the first element for which (PRED element) is non-nil in SEQ. 274 "Return the first element for which (PRED element) is non-nil in SEQ.
275If no element is found, return SENTINEL or nil. 275If no element is found, return DEFAULT.
276 276
277Note that `seq-find' has an ambiguity if the found element is nil 277Note that `seq-find' has an ambiguity if the found element is
278and if no SENTINEL is specified, as it cannot be known if an 278identical to DEFAULT, as it cannot be known if an element was
279element was found or not." 279found or not."
280 (catch 'seq--break 280 (catch 'seq--break
281 (seq-doseq (elt seq) 281 (seq-doseq (elt seq)
282 (when (funcall pred elt) 282 (when (funcall pred elt)
283 (throw 'seq--break elt))) 283 (throw 'seq--break elt)))
284 sentinel)) 284 default))
285 285
286(cl-defgeneric seq-count (pred seq) 286(cl-defgeneric seq-count (pred seq)
287 "Return the number of elements for which (PRED element) is non-nil in SEQ." 287 "Return the number of elements for which (PRED element) is non-nil in SEQ."