GNU bug report logs - #2042
Ido-mode : filtering does not keep ordering

Previous Next

Package: emacs;

Reported by: Antoine Levitt <smeuuh <at> gmail.com>

Date: Sun, 25 Jan 2009 14:00:03 UTC

Severity: wishlist

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 2042 in the body.
You can then email your comments to 2042 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2042; Package emacs. (Sun, 25 Jan 2009 14:00:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Antoine Levitt <smeuuh <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sun, 25 Jan 2009 14:00:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Antoine Levitt <smeuuh <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Ido-mode : filtering does not keep ordering
Date: Sun, 25 Jan 2009 14:54:28 +0100
[Message part 1 (text/plain, inline)]
Hi,
When buffer switching in Ido, filtering the list of available buffers does
not keep the original ordering of buffers (from most recent to oldest).
Ie if I have for instance buffers foobar and barfoo, in this order, if I
type bar, they are displayed to me as barfoo foobar. I understand this is a
reasonable behavior in a number of case, but it's annoying when using ido to
quickly toggle between working buffers, where I have old and forgotten
buffers pop up as the first option in the completion list. Would it be
possible to add a switch ?

Antoine Levitt
[Message part 2 (text/html, inline)]

Severity set to `wishlist' from `normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 29 Jan 2009 01:15:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sat, 24 Sep 2011 16:22:01 GMT) Full text and rfc822 format available.

Message #10 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Antoine Levitt <smeuuh <at> gmail.com>
Cc: 2042 <at> debbugs.gnu.org
Subject: Re: Ido-mode : filtering does not keep ordering
Date: Sun, 25 Sep 2011 00:20:27 +0800
On 2009-01-25 21:54 +0800, Antoine Levitt wrote:
> Hi,
> When buffer switching in Ido, filtering the list of available buffers does
> not keep the original ordering of buffers (from most recent to oldest).
> Ie if I have for instance buffers foobar and barfoo, in this order, if I
> type bar, they are displayed to me as barfoo foobar. I understand this is a
> reasonable behavior in a number of case, but it's annoying when using ido to
> quickly toggle between working buffers, where I have old and forgotten
> buffers pop up as the first option in the completion list. Would it be
> possible to add a switch ?
>
> Antoine Levitt

I occasionally try iswitch-mode and find its buffer switching much more
pleasant to use than ido's. The trouble is ido tries to be smart in
ordering matches. Sadly that gets in the way most of the time.

I wonder if people are willing to try the following (preliminary) patch
and see if they miss anything.

diff --git a/lisp/ido.el b/lisp/ido.el
index aa6ad4aa..e0640eba 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3735,7 +3735,7 @@ (defun ido-get-bufname (win)
 
 ;;; FIND MATCHING ITEMS
 
-(defun ido-set-matches-1 (items &optional do-full)
+(defun ido-set-matches-1 (items &optional ignore)
   ;; Return list of matches in items
   (let* ((case-fold-search  ido-case-fold)
 	 (slash (and (not ido-enable-prefix) (ido-final-slash ido-text)))
@@ -3743,18 +3743,11 @@ (defun ido-set-matches-1 (items &optional do-full)
 	 (rex0 (if ido-enable-regexp text (regexp-quote text)))
 	 (rexq (concat rex0 (if slash ".*/" "")))
 	 (re (if ido-enable-prefix (concat "\\`" rexq) rexq))
-	 (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
-		       (concat "\\`" rex0 (if slash "/" "") "\\'")))
-	 (suffix-re (and do-full slash
-			 (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
-			 (concat rex0 "/\\'")))
-	 (prefix-re (and full-re (not ido-enable-prefix)
-			 (concat "\\`" rexq)))
 	 (non-prefix-dot (or (not ido-enable-dot-prefix)
 			     (not ido-process-ignore-lists)
 			     ido-enable-prefix
 			     (= (length ido-text) 0)))
-	 full-matches suffix-matches prefix-matches matches)
+	 matches)
     (setq ido-incomplete-regexp nil)
     (condition-case error
         (mapc
@@ -3771,12 +3764,6 @@ (defun ido-set-matches-1 (items &optional do-full)
 			    (not (string= name ido-default-item)))
 			(string= name (buffer-name ido-entry-buffer)))
 		   (setq matches (cons item matches)))
-		  ((and full-re (string-match full-re name))
-		   (setq full-matches (cons item full-matches)))
-		  ((and suffix-re (string-match suffix-re name))
-		   (setq suffix-matches (cons item suffix-matches)))
-		  ((and prefix-re (string-match prefix-re name))
-		   (setq prefix-matches (cons item prefix-matches)))
 		  (t (setq matches (cons item matches))))))
 	   t)
          items)
@@ -3786,16 +3773,6 @@ (defun ido-set-matches-1 (items &optional do-full)
              ;; special-case single match, and handle appropriately
              ;; elsewhere.
              matches (cdr error))))
-    (when prefix-matches
-      (ido-trace "prefix match" prefix-matches)
-      ;; Bug#2042.
-      (setq matches (nconc prefix-matches matches)))
-    (when suffix-matches
-      (ido-trace "suffix match" (list text suffix-re suffix-matches))
-      (setq matches (nconc suffix-matches matches)))
-    (when full-matches
-      (ido-trace "full match" (list text full-re full-matches))
-      (setq matches (nconc full-matches matches)))
     (when (and (null matches)
 	       ido-enable-flex-matching
 	       (> (length ido-text) 1)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sun, 25 Sep 2011 08:56:02 GMT) Full text and rfc822 format available.

Message #13 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Antoine Levitt <antoine.levitt <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sun, 25 Sep 2011 10:54:50 +0200
24/09/11 18:20, Leo
> On 2009-01-25 21:54 +0800, Antoine Levitt wrote:
>> Hi,
>> When buffer switching in Ido, filtering the list of available buffers does
>> not keep the original ordering of buffers (from most recent to oldest).
>> Ie if I have for instance buffers foobar and barfoo, in this order, if I
>> type bar, they are displayed to me as barfoo foobar. I understand this is a
>> reasonable behavior in a number of case, but it's annoying when using ido to
>> quickly toggle between working buffers, where I have old and forgotten
>> buffers pop up as the first option in the completion list. Would it be
>> possible to add a switch ?
>>
>> Antoine Levitt
>
> I occasionally try iswitch-mode and find its buffer switching much more
> pleasant to use than ido's. The trouble is ido tries to be smart in
> ordering matches. Sadly that gets in the way most of the time.
>
> I wonder if people are willing to try the following (preliminary) patch
> and see if they miss anything.

That's much better! Thanks!





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sat, 01 Oct 2011 19:13:02 GMT) Full text and rfc822 format available.

Message #16 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Leo <sdl.web <at> gmail.com>
Cc: 2042 <at> debbugs.gnu.org, Antoine Levitt <smeuuh <at> gmail.com>
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sat, 01 Oct 2011 15:10:56 -0400
Leo <sdl.web <at> gmail.com> writes:

> I occasionally try iswitch-mode and find its buffer switching much
> more pleasant to use than ido's. The trouble is ido tries to be smart
> in ordering matches. Sadly that gets in the way most of the time.

Could you explain in words what the existing code tries to do?

Maybe it's indeed misguided and ought to be taken out, but it would be
good to first figure out what the original intention was.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sun, 02 Oct 2011 00:07:02 GMT) Full text and rfc822 format available.

Message #19 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: 2042 <at> debbugs.gnu.org, Antoine Levitt <smeuuh <at> gmail.com>
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sun, 02 Oct 2011 08:04:30 +0800
On 2011-10-02 03:10 +0800, Chong Yidong wrote:
> Leo <sdl.web <at> gmail.com> writes:
>
>> I occasionally try iswitch-mode and find its buffer switching much
>> more pleasant to use than ido's. The trouble is ido tries to be smart
>> in ordering matches. Sadly that gets in the way most of the time.
>
> Could you explain in words what the existing code tries to do?
>
> Maybe it's indeed misguided and ought to be taken out, but it would be
> good to first figure out what the original intention was.

The existing code gives different precedence to different match type:

 full-matches > suffix matches > prefix matches > remaining matches

For example in switching buffers in ido:

input: ab

Buffer: ab[c]{abcd | abc | xabcd | xabc}

now when the user types c, it changes to:

Buffer: abc{abc | abcd | xabcd | xabc}

Note the different ordering of "abcd" and "abc". Because typing is so
much quicker than observing the new order, one usually mis-chooses a
match.

Thus, the above strategy may break down when the original ordering is
meaningful for example, (buffer-list) returns a list in order of
recency.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sat, 29 Oct 2011 06:41:02 GMT) Full text and rfc822 format available.

Message #22 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 2042 <at> debbugs.gnu.org, Antoine Levitt <smeuuh <at> gmail.com>
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sat, 29 Oct 2011 14:38:01 +0800
Leo <sdl.web <at> gmail.com> writes:

> The existing code gives different precedence to different match type:
>
>  full-matches > suffix matches > prefix matches > remaining matches
>
> For example in switching buffers in ido:
>
> input: ab
>
> Buffer: ab[c]{abcd | abc | xabcd | xabc}
>
> now when the user types c, it changes to:
>
> Buffer: abc{abc | abcd | xabcd | xabc}
>
> Note the different ordering of "abcd" and "abc". Because typing is so
> much quicker than observing the new order, one usually mis-chooses a
> match.

Thanks.  I guess since at least two users of ido have complained about
this behavior, and no one else has chimed in, we can go ahead and make
this change after the release.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sat, 29 Oct 2011 07:09:02 GMT) Full text and rfc822 format available.

Message #25 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sat, 29 Oct 2011 15:06:11 +0800
On 2011-10-29 14:38 +0800, Chong Yidong wrote:
> Thanks.  I guess since at least two users of ido have complained about
> this behavior, and no one else has chimed in, we can go ahead and make
> this change after the release.

OK. Maybe we can also add a user option.

Leo





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sun, 16 Sep 2012 09:31:01 GMT) Full text and rfc822 format available.

Message #28 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Matthew Woodcraft <matthew <at> woodcraft.me.uk>
To: Chong Yidong <cyd <at> gnu.org>
Cc: Antoine Levitt <smeuuh <at> gmail.com>, Leo <sdl.web <at> gmail.com>,
	2042 <at> debbugs.gnu.org
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sun, 16 Sep 2012 10:29:06 +0100
On 29 Oct 2011, Chong Yidong <cyd <at> gnu.org> wrote:
> Thanks. I guess since at least two users of ido have complained about
> this behavior, and no one else has chimed in, we can go ahead and make
> this change after the release.

I've been running with Leo's patch from this bug report for a couple of
months.

I also think that the changed behaviour is an improvement, and I've seen
no problems.

So could this be considered before the 24.3 freeze?

-M-




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sun, 16 Sep 2012 14:57:01 GMT) Full text and rfc822 format available.

Message #31 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Matthew Woodcraft <matthew <at> woodcraft.me.uk>
Cc: Chong Yidong <cyd <at> gnu.org>, Antoine Levitt <smeuuh <at> gmail.com>,
	2042 <at> debbugs.gnu.org
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sun, 16 Sep 2012 22:55:30 +0800
On 2012-09-16 17:29 +0800, Matthew Woodcraft wrote:
> I've been running with Leo's patch from this bug report for a couple of
> months.
>
> I also think that the changed behaviour is an improvement, and I've seen
> no problems.
>
> So could this be considered before the 24.3 freeze?

If Yidong doesn't object, I plan to commit something along these lines:

diff --git a/lisp/ido.el b/lisp/ido.el
index fe94c7f2..bb019574 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -493,6 +493,17 @@ (defcustom ido-enable-dot-prefix nil
   :type 'boolean
   :group 'ido)
 
+;; See http://debbugs.gnu.org/2042 for more info.
+(defcustom ido-buffer-disable-smart-matches t
+  "Non-nil means not to re-order matches for buffer switching.
+By default, ido aranges matches in the following order:
+
+  full-matches > suffix matches > prefix matches > remaining matches
+
+which can get in the way for buffer switching."
+  :type 'boolean
+  :group 'ido)
+
 (defcustom ido-confirm-unique-completion nil
   "Non-nil means that even a unique completion must be confirmed.
 This means that \\[ido-complete] must always be followed by \\[ido-exit-minibuffer]
@@ -3688,10 +3699,15 @@ (defun ido-set-matches-1 (items &optional do-full)
 	 (rex0 (if ido-enable-regexp text (regexp-quote text)))
 	 (rexq (concat rex0 (if slash ".*/" "")))
 	 (re (if ido-enable-prefix (concat "\\`" rexq) rexq))
-	 (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+	 (full-re (and do-full
+		       (not ido-buffer-disable-smart-matches)
+		       (not ido-enable-regexp)
+		       (not (string-match "\$\\'" rex0))
 		       (concat "\\`" rex0 (if slash "/" "") "\\'")))
 	 (suffix-re (and do-full slash
-			 (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+			 (not ido-buffer-disable-smart-matches)
+			 (not ido-enable-regexp)
+			 (not (string-match "\$\\'" rex0))
 			 (concat rex0 "/\\'")))
 	 (prefix-re (and full-re (not ido-enable-prefix)
 			 (concat "\\`" rexq)))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sun, 16 Sep 2012 15:05:02 GMT) Full text and rfc822 format available.

Message #34 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: 2042 <at> debbugs.gnu.org
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Sun, 16 Sep 2012 23:03:15 +0800
Use this patch instead:

diff --git a/lisp/ido.el b/lisp/ido.el
index fe94c7f2..512ac9d4 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -493,6 +493,17 @@ (defcustom ido-enable-dot-prefix nil
   :type 'boolean
   :group 'ido)
 
+;; See http://debbugs.gnu.org/2042 for more info.
+(defcustom ido-buffer-disable-smart-matches t
+  "Non-nil means not to re-order matches for buffer switching.
+By default, ido aranges matches in the following order:
+
+  full-matches > suffix matches > prefix matches > remaining matches
+
+which can get in the way for buffer switching."
+  :type 'boolean
+  :group 'ido)
+
 (defcustom ido-confirm-unique-completion nil
   "Non-nil means that even a unique completion must be confirmed.
 This means that \\[ido-complete] must always be followed by \\[ido-exit-minibuffer]
@@ -3688,10 +3699,17 @@ (defun ido-set-matches-1 (items &optional do-full)
 	 (rex0 (if ido-enable-regexp text (regexp-quote text)))
 	 (rexq (concat rex0 (if slash ".*/" "")))
 	 (re (if ido-enable-prefix (concat "\\`" rexq) rexq))
-	 (full-re (and do-full (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+	 (full-re (and do-full
+		       (and (eq ido-cur-item 'buffer)
+			    (not ido-buffer-disable-smart-matches))
+		       (not ido-enable-regexp)
+		       (not (string-match "\$\\'" rex0))
 		       (concat "\\`" rex0 (if slash "/" "") "\\'")))
 	 (suffix-re (and do-full slash
-			 (not ido-enable-regexp) (not (string-match "\$\\'" rex0))
+			 (and (eq ido-cur-item 'buffer)
+			      (not ido-buffer-disable-smart-matches))
+			 (not ido-enable-regexp)
+			 (not (string-match "\$\\'" rex0))
 			 (concat rex0 "/\\'")))
 	 (prefix-re (and full-re (not ido-enable-prefix)
 			 (concat "\\`" rexq)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2042; Package emacs. (Sun, 16 Sep 2012 16:35:02 GMT) Full text and rfc822 format available.

Message #37 received at 2042 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Leo <sdl.web <at> gmail.com>
Cc: 2042 <at> debbugs.gnu.org
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Mon, 17 Sep 2012 00:33:11 +0800
Leo <sdl.web <at> gmail.com> writes:

> Use this patch instead:

Feel free to commit, and thanks for writing up the patch.




Reply sent to Leo <sdl.web <at> gmail.com>:
You have taken responsibility. (Sun, 16 Sep 2012 22:30:01 GMT) Full text and rfc822 format available.

Notification sent to Antoine Levitt <smeuuh <at> gmail.com>:
bug acknowledged by developer. (Sun, 16 Sep 2012 22:30:02 GMT) Full text and rfc822 format available.

Message #42 received at 2042-done <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: 2042-done <at> debbugs.gnu.org
Subject: Re: bug#2042: Ido-mode : filtering does not keep ordering
Date: Mon, 17 Sep 2012 06:28:21 +0800
Fixed in emacs-24




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 15 Oct 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 44 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.