diff options
| author | Damien Cassou | 2022-09-04 13:00:22 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-09-04 13:00:22 +0200 |
| commit | 77b761dafaf65d57dd05ecd586884340fa4e63e2 (patch) | |
| tree | fbe9e9fa8870622b04b1b69fea72d56aeb88d361 | |
| parent | 40de3684fb824c797fa942ad5f99ca319aa34881 (diff) | |
| download | emacs-77b761dafaf65d57dd05ecd586884340fa4e63e2.tar.gz emacs-77b761dafaf65d57dd05ecd586884340fa4e63e2.zip | |
Improve documentation of several functions in seq.el
* doc/lispref/sequences.texi (Sequence Functions):
* lisp/emacs-lisp/seq.el (seq-contains):
(seq-contains-p):
(seq-set-equal-p):
(seq-position):
(seq-union):
(seq-intersection):
(seq-difference): Use more standard wording in the docstrings
(bug#57561).
| -rw-r--r-- | doc/lispref/sequences.texi | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/seq.el | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index 1f6f80521c0..cc956952d6f 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi | |||
| @@ -863,7 +863,7 @@ arguments to use instead of the default @code{equal}. | |||
| 863 | @end defun | 863 | @end defun |
| 864 | 864 | ||
| 865 | @defun seq-position sequence elt &optional function | 865 | @defun seq-position sequence elt &optional function |
| 866 | This function returns the index of the first element in | 866 | This function returns the (zero-based) index of the first element in |
| 867 | @var{sequence} that is equal to @var{elt}. If the optional argument | 867 | @var{sequence} that is equal to @var{elt}. If the optional argument |
| 868 | @var{function} is non-@code{nil}, it is a function of two arguments to | 868 | @var{function} is non-@code{nil}, it is a function of two arguments to |
| 869 | use instead of the default @code{equal}. | 869 | use instead of the default @code{equal}. |
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 1b4a49e4e32..b5f762ef3ac 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el | |||
| @@ -409,7 +409,7 @@ found or not." | |||
| 409 | 409 | ||
| 410 | (cl-defgeneric seq-contains (sequence elt &optional testfn) | 410 | (cl-defgeneric seq-contains (sequence elt &optional testfn) |
| 411 | "Return the first element in SEQUENCE that is equal to ELT. | 411 | "Return the first element in SEQUENCE that is equal to ELT. |
| 412 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 412 | Equality is defined by the function TESTFN, which defaults to `equal'." |
| 413 | (declare (obsolete seq-contains-p "27.1")) | 413 | (declare (obsolete seq-contains-p "27.1")) |
| 414 | (seq-some (lambda (e) | 414 | (seq-some (lambda (e) |
| 415 | (when (funcall (or testfn #'equal) elt e) | 415 | (when (funcall (or testfn #'equal) elt e) |
| @@ -418,7 +418,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." | |||
| 418 | 418 | ||
| 419 | (cl-defgeneric seq-contains-p (sequence elt &optional testfn) | 419 | (cl-defgeneric seq-contains-p (sequence elt &optional testfn) |
| 420 | "Return non-nil if SEQUENCE contains an element equal to ELT. | 420 | "Return non-nil if SEQUENCE contains an element equal to ELT. |
| 421 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 421 | Equality is defined by the function TESTFN, which defaults to `equal'." |
| 422 | (catch 'seq--break | 422 | (catch 'seq--break |
| 423 | (seq-doseq (e sequence) | 423 | (seq-doseq (e sequence) |
| 424 | (let ((r (funcall (or testfn #'equal) e elt))) | 424 | (let ((r (funcall (or testfn #'equal) e elt))) |
| @@ -429,14 +429,14 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." | |||
| 429 | (cl-defgeneric seq-set-equal-p (sequence1 sequence2 &optional testfn) | 429 | (cl-defgeneric seq-set-equal-p (sequence1 sequence2 &optional testfn) |
| 430 | "Return non-nil if SEQUENCE1 and SEQUENCE2 contain the same elements. | 430 | "Return non-nil if SEQUENCE1 and SEQUENCE2 contain the same elements. |
| 431 | This does not depend on the order of the elements. | 431 | This does not depend on the order of the elements. |
| 432 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 432 | Equality is defined by the function TESTFN, which defaults to `equal'." |
| 433 | (and (seq-every-p (lambda (item1) (seq-contains-p sequence2 item1 testfn)) sequence1) | 433 | (and (seq-every-p (lambda (item1) (seq-contains-p sequence2 item1 testfn)) sequence1) |
| 434 | (seq-every-p (lambda (item2) (seq-contains-p sequence1 item2 testfn)) sequence2))) | 434 | (seq-every-p (lambda (item2) (seq-contains-p sequence1 item2 testfn)) sequence2))) |
| 435 | 435 | ||
| 436 | ;;;###autoload | 436 | ;;;###autoload |
| 437 | (cl-defgeneric seq-position (sequence elt &optional testfn) | 437 | (cl-defgeneric seq-position (sequence elt &optional testfn) |
| 438 | "Return the index of the first element in SEQUENCE that is equal to ELT. | 438 | "Return the (zero-based) index of the first element in SEQUENCE equal to ELT. |
| 439 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 439 | Equality is defined by the function TESTFN, which defaults to `equal'." |
| 440 | (let ((index 0)) | 440 | (let ((index 0)) |
| 441 | (catch 'seq--break | 441 | (catch 'seq--break |
| 442 | (seq-doseq (e sequence) | 442 | (seq-doseq (e sequence) |
| @@ -502,7 +502,7 @@ negative integer or 0, nil is returned." | |||
| 502 | ;;;###autoload | 502 | ;;;###autoload |
| 503 | (cl-defgeneric seq-union (sequence1 sequence2 &optional testfn) | 503 | (cl-defgeneric seq-union (sequence1 sequence2 &optional testfn) |
| 504 | "Return a list of all elements that appear in either SEQUENCE1 or SEQUENCE2. | 504 | "Return a list of all elements that appear in either SEQUENCE1 or SEQUENCE2. |
| 505 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 505 | Equality is defined by the function TESTFN, which defaults to `equal'." |
| 506 | (let* ((accum (lambda (acc elt) | 506 | (let* ((accum (lambda (acc elt) |
| 507 | (if (seq-contains-p acc elt testfn) | 507 | (if (seq-contains-p acc elt testfn) |
| 508 | acc | 508 | acc |
| @@ -514,7 +514,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." | |||
| 514 | ;;;###autoload | 514 | ;;;###autoload |
| 515 | (cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn) | 515 | (cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn) |
| 516 | "Return a list of the elements that appear in both SEQUENCE1 and SEQUENCE2. | 516 | "Return a list of the elements that appear in both SEQUENCE1 and SEQUENCE2. |
| 517 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 517 | Equality is defined by the function TESTFN, which defaults to `equal'." |
| 518 | (seq-reduce (lambda (acc elt) | 518 | (seq-reduce (lambda (acc elt) |
| 519 | (if (seq-contains-p sequence2 elt testfn) | 519 | (if (seq-contains-p sequence2 elt testfn) |
| 520 | (cons elt acc) | 520 | (cons elt acc) |
| @@ -524,7 +524,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." | |||
| 524 | 524 | ||
| 525 | (cl-defgeneric seq-difference (sequence1 sequence2 &optional testfn) | 525 | (cl-defgeneric seq-difference (sequence1 sequence2 &optional testfn) |
| 526 | "Return a list of the elements that appear in SEQUENCE1 but not in SEQUENCE2. | 526 | "Return a list of the elements that appear in SEQUENCE1 but not in SEQUENCE2. |
| 527 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 527 | Equality is defined by the function TESTFN, which defaults to `equal'." |
| 528 | (seq-reduce (lambda (acc elt) | 528 | (seq-reduce (lambda (acc elt) |
| 529 | (if (seq-contains-p sequence2 elt testfn) | 529 | (if (seq-contains-p sequence2 elt testfn) |
| 530 | acc | 530 | acc |