From: Leo Liu Date: Wed, 8 May 2013 14:22:24 +0000 (+0800) Subject: Re-work a fix for bug#10994 based on Le Wang's patch. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~250 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ea78b95b03f94ea9675d7afdcc01c29d63e6a32a;p=emacs.git Re-work a fix for bug#10994 based on Le Wang's patch. * ido.el (ido-remove-consecutive-dups): New helper. (ido-completing-read): Use it. (ido-chop): Revert fix for bug#10994. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 76ae9231820..cd5d2f4ee61 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-05-08 Leo Liu + + Re-work a fix for bug#10994 based on Le Wang's patch. + * ido.el (ido-remove-consecutive-dups): New helper. + (ido-completing-read): Use it. + (ido-chop): Revert fix for bug#10994. + 2013-05-08 Adam Spiers * cus-edit.el (custom-save-variables): diff --git a/lisp/ido.el b/lisp/ido.el index bedf00e638d..297e3258338 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -3152,15 +3152,13 @@ for first matching file." (exit-minibuffer))) (defun ido-chop (items elem) - "Remove all elements before ELEM and put them at the end of ITEMS. -Use `eq' for comparison." + "Remove all elements before ELEM and put them at the end of ITEMS." (let ((ret nil) (next nil) (sofar nil)) (while (not ret) (setq next (car items)) - ;; Use `eq' to avoid bug http://debbugs.gnu.org/10994 - (if (eq next elem) + (if (equal next elem) (setq ret (append items (nreverse sofar))) ;; else (progn @@ -4678,6 +4676,21 @@ For details of keybindings, see `ido-find-file'." ido-temp-list)))) (ido-to-end summaries))) +(defun ido-remove-consecutive-dups (list) + "Remove consecutive duplicates in LIST. +Use `equal' for comparison. First and last elements are +considered consecutive." + (let ((tail list) + (last (make-symbol "")) + (result nil)) + (while (consp tail) + (unless (equal (car tail) last) + (push (setq last (car tail)) result)) + (setq tail (cdr tail))) + (nreverse (or (and (equal last (car list)) + (cdr result)) + result)))) + ;;; Helper functions for other programs (put 'dired-do-rename 'ido 'ignore) @@ -4795,7 +4808,7 @@ DEF, if non-nil, is the default value." (ido-directory-nonreadable nil) (ido-directory-too-big nil) (ido-context-switch-command 'ignore) - (ido-choice-list choices)) + (ido-choice-list (ido-remove-consecutive-dups choices))) ;; Initialize ido before invoking ido-read-internal (ido-common-initialization) (ido-read-internal 'list prompt hist def require-match initial-input)))