diff options
author | Leo Liu <sdl.web@gmail.com> | 2013-05-17 10:43:41 +0800 |
---|---|---|
committer | Leo Liu <sdl.web@gmail.com> | 2013-05-17 10:43:41 +0800 |
commit | c7a8fcacf99548e19b4efcf6900abc66c1de3a9d (patch) | |
tree | 64b94a2652784a8e938b7e8013df6d72d3a4a3cf /lisp/subr.el | |
parent | f678b18a19e3c8050acfde90523b1542e4537053 (diff) | |
download | emacs-c7a8fcacf99548e19b4efcf6900abc66c1de3a9d.tar.gz emacs-c7a8fcacf99548e19b4efcf6900abc66c1de3a9d.tar.bz2 emacs-c7a8fcacf99548e19b4efcf6900abc66c1de3a9d.zip |
* subr.el (delete-consecutive-dups): New function.
* ido.el (ido-set-matches-1): Use it.
* progmodes/octave.el (inferior-octave-completion-table): Use it.
* ido.el (ido-remove-consecutive-dups): Remove.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 9bf11a13ef6..9b2c8157ac8 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -376,6 +376,23 @@ one is kept." (setq tail (cdr tail)))) list) +;; See http://lists.gnu.org/archive/html/emacs-devel/2013-05/msg00204.html +(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." + (let ((tail list) last) + (while (consp tail) + (if (equal (car tail) (cadr tail)) + (setcdr tail (cddr tail)) + (setq last (car tail) + tail (cdr tail)))) + (if (and circular + (cdr list) + (equal last (car list))) + (nbutlast list) + list))) + (defun number-sequence (from &optional to inc) "Return a sequence of numbers from FROM to TO (both inclusive) as a list. INC is the increment used between numbers in the sequence and defaults to 1. |