diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-02-26 14:34:58 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-02-27 10:03:23 +0100 |
commit | 434ab2e08895bdf952de78aea285da33be63c954 (patch) | |
tree | 07a09150928f785f3eacd9fc3ea5ca824c338d42 /lisp/subr.el | |
parent | c640dc9ef533c1fa68cf7b29f63a3fb32e4c3b06 (diff) | |
download | emacs-434ab2e08895bdf952de78aea285da33be63c954.tar.gz |
Improve delete-consecutive-dups doc precision and add test
* lisp/subr.el (delete-consecutive-dups): Document which element of
each run is retained (the earliest in the list). This matters because
it makes it safe to ignore the return value.
* test/lisp/subr-tests.el (subr--delete-dups)
(subr--delete-consecutive-dups): Add tests.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 916b6de494b..ef2f63f7c37 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -768,7 +768,9 @@ one is kept. See `seq-uniq' for non-destructive operation." (defun delete-consecutive-dups (list &optional circular) "Destructively remove `equal' consecutive duplicates from LIST. First and last elements are considered consecutive if CIRCULAR is -non-nil." +non-nil. +Of several consecutive `equal' occurrences, the one earliest in +the list is kept." (let ((tail list) last) (while (cdr tail) (if (equal (car tail) (cadr tail)) |