diff options
| author | Leo Liu | 2013-05-17 10:43:41 +0800 |
|---|---|---|
| committer | Leo Liu | 2013-05-17 10:43:41 +0800 |
| commit | c7a8fcacf99548e19b4efcf6900abc66c1de3a9d (patch) | |
| tree | 64b94a2652784a8e938b7e8013df6d72d3a4a3cf | |
| parent | f678b18a19e3c8050acfde90523b1542e4537053 (diff) | |
| download | emacs-c7a8fcacf99548e19b4efcf6900abc66c1de3a9d.tar.gz 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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/ido.el | 19 | ||||
| -rw-r--r-- | lisp/progmodes/octave.el | 8 | ||||
| -rw-r--r-- | lisp/subr.el | 17 |
4 files changed, 31 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 78eefc86500..4a060875e3c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-05-17 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * subr.el (delete-consecutive-dups): New function. | ||
| 4 | * ido.el (ido-set-matches-1): Use it. | ||
| 5 | * progmodes/octave.el (inferior-octave-completion-table): Use it. | ||
| 6 | * ido.el (ido-remove-consecutive-dups): Remove. | ||
| 7 | |||
| 1 | 2013-05-17 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2013-05-17 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * progmodes/f90.el (f90-keywords-re, f90-keywords-level-3-re) | 10 | * progmodes/f90.el (f90-keywords-re, f90-keywords-level-3-re) |
diff --git a/lisp/ido.el b/lisp/ido.el index 297e3258338..8087124765c 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -3785,7 +3785,7 @@ This is to make them appear as if they were \"virtual buffers\"." | |||
| 3785 | (if (string-match re name) | 3785 | (if (string-match re name) |
| 3786 | (setq matches (cons item matches))))) | 3786 | (setq matches (cons item matches))))) |
| 3787 | items)) | 3787 | items)) |
| 3788 | matches)) | 3788 | (delete-consecutive-dups matches t))) |
| 3789 | 3789 | ||
| 3790 | 3790 | ||
| 3791 | (defun ido-set-matches () | 3791 | (defun ido-set-matches () |
| @@ -4676,21 +4676,6 @@ For details of keybindings, see `ido-find-file'." | |||
| 4676 | ido-temp-list)))) | 4676 | ido-temp-list)))) |
| 4677 | (ido-to-end summaries))) | 4677 | (ido-to-end summaries))) |
| 4678 | 4678 | ||
| 4679 | (defun ido-remove-consecutive-dups (list) | ||
| 4680 | "Remove consecutive duplicates in LIST. | ||
| 4681 | Use `equal' for comparison. First and last elements are | ||
| 4682 | considered consecutive." | ||
| 4683 | (let ((tail list) | ||
| 4684 | (last (make-symbol "")) | ||
| 4685 | (result nil)) | ||
| 4686 | (while (consp tail) | ||
| 4687 | (unless (equal (car tail) last) | ||
| 4688 | (push (setq last (car tail)) result)) | ||
| 4689 | (setq tail (cdr tail))) | ||
| 4690 | (nreverse (or (and (equal last (car list)) | ||
| 4691 | (cdr result)) | ||
| 4692 | result)))) | ||
| 4693 | |||
| 4694 | ;;; Helper functions for other programs | 4679 | ;;; Helper functions for other programs |
| 4695 | 4680 | ||
| 4696 | (put 'dired-do-rename 'ido 'ignore) | 4681 | (put 'dired-do-rename 'ido 'ignore) |
| @@ -4808,7 +4793,7 @@ DEF, if non-nil, is the default value." | |||
| 4808 | (ido-directory-nonreadable nil) | 4793 | (ido-directory-nonreadable nil) |
| 4809 | (ido-directory-too-big nil) | 4794 | (ido-directory-too-big nil) |
| 4810 | (ido-context-switch-command 'ignore) | 4795 | (ido-context-switch-command 'ignore) |
| 4811 | (ido-choice-list (ido-remove-consecutive-dups choices))) | 4796 | (ido-choice-list choices)) |
| 4812 | ;; Initialize ido before invoking ido-read-internal | 4797 | ;; Initialize ido before invoking ido-read-internal |
| 4813 | (ido-common-initialization) | 4798 | (ido-common-initialization) |
| 4814 | (ido-read-internal 'list prompt hist def require-match initial-input))) | 4799 | (ido-read-internal 'list prompt hist def require-match initial-input))) |
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index ab2f570cccb..451ac2791a7 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el | |||
| @@ -38,7 +38,9 @@ | |||
| 38 | (require 'newcomment) | 38 | (require 'newcomment) |
| 39 | (eval-and-compile | 39 | (eval-and-compile |
| 40 | (unless (fboundp 'user-error) | 40 | (unless (fboundp 'user-error) |
| 41 | (defalias 'user-error 'error))) | 41 | (defalias 'user-error 'error)) |
| 42 | (unless (fboundp 'delete-consecutive-dups) | ||
| 43 | (defalias 'delete-consecutive-dups 'delete-dups))) | ||
| 42 | (eval-when-compile | 44 | (eval-when-compile |
| 43 | (unless (fboundp 'setq-local) | 45 | (unless (fboundp 'setq-local) |
| 44 | (defmacro setq-local (var val) | 46 | (defmacro setq-local (var val) |
| @@ -777,8 +779,8 @@ startup file, `~/.emacs-octave'." | |||
| 777 | (inferior-octave-send-list-and-digest | 779 | (inferior-octave-send-list-and-digest |
| 778 | (list (concat "completion_matches (\"" command "\");\n"))) | 780 | (list (concat "completion_matches (\"" command "\");\n"))) |
| 779 | (setq cache (list command (float-time) | 781 | (setq cache (list command (float-time) |
| 780 | (sort (delete-dups inferior-octave-output-list) | 782 | (delete-consecutive-dups |
| 781 | 'string-lessp)))) | 783 | (sort inferior-octave-output-list 'string-lessp))))) |
| 782 | (car (cddr cache)))))) | 784 | (car (cddr cache)))))) |
| 783 | 785 | ||
| 784 | (defun inferior-octave-completion-at-point () | 786 | (defun inferior-octave-completion-at-point () |
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." | |||
| 376 | (setq tail (cdr tail)))) | 376 | (setq tail (cdr tail)))) |
| 377 | list) | 377 | list) |
| 378 | 378 | ||
| 379 | ;; See http://lists.gnu.org/archive/html/emacs-devel/2013-05/msg00204.html | ||
| 380 | (defun delete-consecutive-dups (list &optional circular) | ||
| 381 | "Destructively remove `equal' consecutive duplicates from LIST. | ||
| 382 | First and last elements are considered consecutive if CIRCULAR is | ||
| 383 | non-nil." | ||
| 384 | (let ((tail list) last) | ||
| 385 | (while (consp tail) | ||
| 386 | (if (equal (car tail) (cadr tail)) | ||
| 387 | (setcdr tail (cddr tail)) | ||
| 388 | (setq last (car tail) | ||
| 389 | tail (cdr tail)))) | ||
| 390 | (if (and circular | ||
| 391 | (cdr list) | ||
| 392 | (equal last (car list))) | ||
| 393 | (nbutlast list) | ||
| 394 | list))) | ||
| 395 | |||
| 379 | (defun number-sequence (from &optional to inc) | 396 | (defun number-sequence (from &optional to inc) |
| 380 | "Return a sequence of numbers from FROM to TO (both inclusive) as a list. | 397 | "Return a sequence of numbers from FROM to TO (both inclusive) as a list. |
| 381 | INC is the increment used between numbers in the sequence and defaults to 1. | 398 | INC is the increment used between numbers in the sequence and defaults to 1. |