emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fix for bug 10994 breaks ido customizations in major way


From: Leo Liu
Subject: Re: fix for bug 10994 breaks ido customizations in major way
Date: Wed, 08 May 2013 12:49:53 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (OS X 10.8.3)

On 2013-05-08 11:29 +0800, Leo Liu wrote:
> It turns out my implementation doesn't modify LIST. So maybe rename it
> to ido-remove-consecutive-dups or change the implementation to work
> in-place.

Missed the case when there is only one element. Patch re-worked as
follows.

diff --git a/lisp/ido.el b/lisp/ido.el
index e335758e..d74733c0 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3170,15 +3170,13 @@ (defun ido-restrict-to-matches ()
     (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
@@ -3806,7 +3804,7 @@ (defun ido-set-matches-1 (items &optional do-full)
           (if (string-match re name)
               (setq matches (cons item matches)))))
        items))
-    matches))
+    (ido-remove-consecutive-dups matches)))
 
 
 (defun ido-set-matches ()
@@ -4729,6 +4727,22 @@ (defun ido-summary-buffers-to-end ()
                              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 (if (and (equal last (car list))
+                      (cdr result))
+                 (cdr result)
+               result))))
+
 ;;; Helper functions for other programs
 
 (put 'dired-do-rename 'ido 'ignore)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]