* Concerning the new `ido-use-virtual-buffers' feature @ 2010-05-26 10:14 Tassilo Horn 2010-05-26 20:59 ` John Wiegley 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-05-26 10:14 UTC (permalink / raw) To: emacs-devel; +Cc: John Wiegley Hi John, first thanks a lot for the ido virtual buffers feature. For years I've regularly switched between iswitchb and ido, because the former had this virtual buffers feature while the latter had more pleasing key bindings, also works for file completion, and some other modes use it. So now, I do have everything I want, except that there is one little inconvenience when comparing iswitchb and ido virtual buffers: The former adds virtual buffers to the possible completions only if no currently open buffer matches the input, whereas ido adds virtual buffers to the completions directly. IMHO, here the iswitchb behavior is a bit more convenient. Currently, I frequently find a virtual buffer file instead of switching to some already open buffer. For example, I want to switch to the buffer "foo.tex", type `C-x b foo RET' and instead find myself in a doc-view buffer opening "foo.pdf"... So is the current behavior intended? Should I write a bug report (feature request)? Bye, Tassilo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-26 10:14 Concerning the new `ido-use-virtual-buffers' feature Tassilo Horn @ 2010-05-26 20:59 ` John Wiegley 2010-05-27 6:54 ` Tassilo Horn 0 siblings, 1 reply; 29+ messages in thread From: John Wiegley @ 2010-05-26 20:59 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel On May 26, 2010, at 4:14 AM, Tassilo Horn wrote: > So now, I do have everything I want, except that there is one little > inconvenience when comparing iswitchb and ido virtual buffers: The > former adds virtual buffers to the possible completions only if no > currently open buffer matches the input, whereas ido adds virtual > buffers to the completions directly. Set `ido-use-virtual-buffers-automatically' to t. :) John ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-26 20:59 ` John Wiegley @ 2010-05-27 6:54 ` Tassilo Horn 2010-05-27 6:57 ` John Wiegley 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-05-27 6:54 UTC (permalink / raw) To: emacs-devel; +Cc: John Wiegley On Wednesday 26 May 2010 22:59:35 John Wiegley wrote: Hi John, > > So now, I do have everything I want, except that there is one little > > inconvenience when comparing iswitchb and ido virtual buffers: The > > former adds virtual buffers to the possible completions only if no > > currently open buffer matches the input, whereas ido adds virtual > > buffers to the completions directly. > > Set `ido-use-virtual-buffers-automatically' to t. :) My Emacs (from bzr trunk, updated a minute ago) doesn't have this variable. :-( Bye, Tassilo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-27 6:54 ` Tassilo Horn @ 2010-05-27 6:57 ` John Wiegley 2010-05-27 8:10 ` Tassilo Horn 0 siblings, 1 reply; 29+ messages in thread From: John Wiegley @ 2010-05-27 6:57 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel On May 27, 2010, at 12:54 AM, Tassilo Horn wrote: >> Set `ido-use-virtual-buffers-automatically' to t. :) > > My Emacs (from bzr trunk, updated a minute ago) doesn't have this > variable. :-( Oh! I'm just waiting on the contributor of that feature to send his papers into the FSF and I can push his change. He said he should be getting the documents this week, so maybe next week it will be in. John ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-27 6:57 ` John Wiegley @ 2010-05-27 8:10 ` Tassilo Horn 2010-05-27 8:26 ` John Wiegley 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-05-27 8:10 UTC (permalink / raw) To: John Wiegley; +Cc: emacs-devel On Thursday 27 May 2010 08:57:14 John Wiegley wrote: Hi John, > >> Set `ido-use-virtual-buffers-automatically' to t. :) > > > > My Emacs (from bzr trunk, updated a minute ago) doesn't have this > > variable. :-( > > Oh! I'm just waiting on the contributor of that feature to send his > papers into the FSF and I can push his change. He said he should be > getting the documents this week, so maybe next week it will be in. Ok, I see. By the way, why is there another variable for that instead of different values to `ido-use-virtual-buffers' (nil, any non-nil and 'automatically)? At least from a user perspective, I'd find that more logical, especially when using `customize'. Bye, Tassilo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-27 8:10 ` Tassilo Horn @ 2010-05-27 8:26 ` John Wiegley 0 siblings, 0 replies; 29+ messages in thread From: John Wiegley @ 2010-05-27 8:26 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel On May 27, 2010, at 2:10 AM, Tassilo Horn wrote: > Ok, I see. By the way, why is there another variable for that instead > of different values to `ido-use-virtual-buffers' (nil, any non-nil and > 'automatically)? At least from a user perspective, I'd find that more > logical, especially when using `customize'. That's a great suggestion. It should be nil, t, or `auto'. John ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature @ 2010-05-27 9:56 Leo 2010-05-27 10:57 ` Tassilo Horn [not found] ` <201006020842.48913.tassilo@member.fsf.org> 0 siblings, 2 replies; 29+ messages in thread From: Leo @ 2010-05-27 9:56 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel Hello Tassilo, > Ok, I see. By the way, why is there another variable for that instead > of different values to `ido-use-virtual-buffers' (nil, any non-nil and > 'automatically)? At least from a user perspective, I'd find that more > logical, especially when using `customize'. My fault. I think I did consider this but I don't remember why I didn't go down that route. It could be I didn't like the slightly more complex way of toggling virtual buffers. I am a bit short of time at the moment but I have put this in my TODO and will look at it again. Meanwhile feel free to change the patch. Turn on virtual buffers automatically when no matches Modified lisp/ido.el diff --git a/lisp/ido.el b/lisp/ido.el index b200397..880592d 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -799,6 +799,14 @@ enabled if this variable is configured to a non-nil value." :type 'integer :group 'ido) +(defcustom ido-use-virtual-buffers-automatically nil + "Use virtual buffers automatically. +If non-nil, virtual buffers are automatically enabled when user +input does not match any existing buffers." + :version "24.1" + :type 'boolean + :group 'ido) + (defcustom ido-use-faces t "Non-nil means use ido faces to highlighting first match, only match and subdirs in the alternatives." @@ -4491,6 +4499,15 @@ For details of keybindings, see `ido-find-file'." (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and ido-use-virtual-buffers-automatically + (eq ido-cur-item 'buffer) + (not ido-matches) + (not ido-use-virtual-buffers)) + (setq ido-text-init ido-text) + (setq ido-use-virtual-buffers t) + (setq ido-exit 'refresh) + (exit-minibuffer)) + (when (and ido-rescan (not ido-matches) Cheers. Leo ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-27 9:56 Leo @ 2010-05-27 10:57 ` Tassilo Horn 2010-05-27 18:01 ` Leo [not found] ` <201006020842.48913.tassilo@member.fsf.org> 1 sibling, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-05-27 10:57 UTC (permalink / raw) To: Leo; +Cc: John Wiegley, Kim F. Storm, emacs-devel [-- Attachment #1: Type: Text/Plain, Size: 823 bytes --] On Thursday 27 May 2010 11:56:53 Leo wrote: Hi Leo, John, Kim, > Meanwhile feel free to change the patch. Hm, it doesn't apply to the current bzr trunk. Anyway, I rewrote it to be controled by the ido-use-virtual-buffers variable solely with 3 values 'never, 'auto, and 'always. The resulting patch is attached. Basically, it works, but there's one bug I cannot figure out how to solve. When ido-use-virtual-buffers is 'auto and the current input doesn't even match any closed buffer (recentf file), then it's stuck instead of displaying [no match]. I don't know ido very well and cannot figure out how to get that right. Kim, maybe you could check what's wrong? I have papers on file. I use 7 lines originating from Leo's patch, so I don't know if that has to wait till Leo's assignments arrive... Bye, Tassilo [-- Attachment #2: ido-virtual-buffers.diff --] [-- Type: text/x-patch, Size: 4474 bytes --] === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-05-27 07:08:37 +0000 +++ lisp/ChangeLog 2010-05-27 10:48:36 +0000 @@ -1,3 +1,14 @@ +2010-05-27 Tassilo Horn <tassilo@member.fsf.org> + + * ido.el (ido-exhibit, ido-buffer-internal) + (ido-toggle-virtual-buffers, ido-make-buffer-list) + (ido-buffer-internal): ido-use-virtual-buffers now is a choice + option with values 'never (default), 'always, and 'auto. The + latter means, show virtual buffers if the current input doesn't + match any existing buffer. + + Based on a patch by Leo <sdl.web@gmail.com>. + 2010-05-27 Kenichi Handa <handa@m17n.org> * language/hebrew.el (hebrew-shape-gstring): Check if a glyph === modified file 'lisp/ido.el' --- lisp/ido.el 2010-05-25 02:11:08 +0000 +++ lisp/ido.el 2010-05-27 10:41:37 +0000 @@ -774,8 +774,10 @@ :type '(repeat string) :group 'ido) -(defcustom ido-use-virtual-buffers nil - "If non-nil, refer to past buffers as well as existing ones. +(defcustom ido-use-virtual-buffers 'never + "If `always', refer to past buffers as well as existing ones. +If `auto', refer to past buffers only when the current input +doesn't match an existing buffer. Essentially it works as follows: Say you are visiting a file and the buffer gets cleaned up by mignight.el. Later, you want to switch to that buffer, but find it's no longer open. With @@ -785,11 +787,12 @@ to think less about whether recently opened files are still open or not. Most of the time you can quit Emacs, restart, and then switch to a file buffer that was previously open as if it still -were. - This feature relies upon the `recentf' package, which will be -enabled if this variable is configured to a non-nil value." +were. This feature relies upon the `recentf' package, which will +be enabled if this variable is configured to a non-nil value." :version "24.1" - :type 'boolean + :type '(choice (const always) + (const auto) + (const never)) :group 'ido) (defcustom ido-use-faces t @@ -1056,7 +1059,7 @@ (defvar ido-virtual-buffers nil "List of virtual buffers, that is, past visited files. This is a copy of `recentf-list', pared down and with faces applied. -Only used if `ido-use-virtual-buffers' is non-nil.") +Only used if `ido-use-virtual-buffers' is not `never'.") ;;; Variables with dynamic bindings. ;;; Declared here to keep the byte compiler quiet. @@ -2182,7 +2185,7 @@ (ido-directory-nonreadable nil) (ido-directory-too-big nil) (ido-use-virtual-buffers (if (eq method 'kill) - nil ;; Don't consider virtual buffers for killing + 'never ;; Don't consider virtual buffers for killing ido-use-virtual-buffers)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default @@ -2224,7 +2227,9 @@ (ido-visit-buffer buf method t))) ;; check for a virtual buffer reference - ((and ido-use-virtual-buffers ido-virtual-buffers + ((and (or (eq ido-use-virtual-buffers 'always) + (eq ido-use-virtual-buffers 'auto)) + ido-virtual-buffers (setq filename (assoc buf ido-virtual-buffers))) (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) @@ -2712,7 +2717,9 @@ See `ido-use-virtual-buffers' for explanation of virtual buffer." (interactive) (when (and ido-mode (eq ido-cur-item 'buffer)) - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) + (setq ido-use-virtual-buffers (if (eq ido-use-virtual-buffers 'never) + 'always + 'never)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) @@ -3403,7 +3410,9 @@ (when (and default (buffer-live-p (get-buffer default))) (setq ido-temp-list (cons default (delete default ido-temp-list)))) - (if ido-use-virtual-buffers + (if (or (eq ido-use-virtual-buffers 'always) + (and (eq ido-use-virtual-buffers 'auto) + (not ido-matches))) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) @@ -4465,6 +4474,13 @@ (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + (not ido-matches)) + (setq ido-text-init ido-text) + (setq ido-exit 'refresh) + (exit-minibuffer)) + (when (and ido-rescan (not ido-matches) ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-27 10:57 ` Tassilo Horn @ 2010-05-27 18:01 ` Leo 2010-05-27 19:05 ` Tassilo Horn 0 siblings, 1 reply; 29+ messages in thread From: Leo @ 2010-05-27 18:01 UTC (permalink / raw) To: Tassilo Horn; +Cc: John Wiegley, Kim F. Storm, emacs-devel Hello all, On 27 May 2010 11:57, Tassilo Horn <tassilo@member.fsf.org> wrote: > On Thursday 27 May 2010 11:56:53 Leo wrote: > > Hi Leo, John, Kim, > >> Meanwhile feel free to change the patch. > > Hm, it doesn't apply to the current bzr trunk. Anyway, I rewrote it to > be controled by the ido-use-virtual-buffers variable solely with 3 > values 'never, 'auto, and 'always. > > The resulting patch is attached. Basically, it works, but there's one > bug I cannot figure out how to solve. When ido-use-virtual-buffers is > 'auto and the current input doesn't even match any closed buffer > (recentf file), then it's stuck instead of displaying [no match]. > > I don't know ido very well and cannot figure out how to get that right. > Kim, maybe you could check what's wrong? I think it is in the added code in ido-exhibit which is run in post-command-hook if I remember correctly. When your input doesn't match any (including virtual ones), the code in ido-exhibit tells ido (the big LOOP in ido-read-internal) to rebuild the buffer list and there isn't any match so it rebuild again and again. Go into a infinite loop. You could try creating a new let-bound variable to detect such a situation and avoid the infinite loop. > I have papers on file. I use 7 lines originating from Leo's patch, so I > don't know if that has to wait till Leo's assignments arrive... > > Bye, > Tassilo HTH, Leo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-27 18:01 ` Leo @ 2010-05-27 19:05 ` Tassilo Horn 2010-05-28 1:21 ` Leo 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-05-27 19:05 UTC (permalink / raw) To: Leo; +Cc: John Wiegley, Kim F. Storm, emacs-devel [-- Attachment #1: Type: Text/Plain, Size: 1328 bytes --] On Thursday 27 May 2010 20:01:04 Leo wrote: Hi Leo, > > The resulting patch is attached. Basically, it works, but there's > > one bug I cannot figure out how to solve. When > > ido-use-virtual-buffers is 'auto and the current input doesn't even > > match any closed buffer (recentf file), then it's stuck instead of > > displaying [no match]. > > > > I don't know ido very well and cannot figure out how to get that > > right. Kim, maybe you could check what's wrong? > > I think it is in the added code in ido-exhibit which is run in > post-command-hook if I remember correctly. > > When your input doesn't match any (including virtual ones), the code > in ido-exhibit tells ido (the big LOOP in ido-read-internal) to > rebuild the buffer list and there isn't any match so it rebuild again > and again. Go into a infinite loop. > > You could try creating a new let-bound variable to detect such a > situation and avoid the infinite loop. Thanks for that. Here's a new patch which uses a new dynamic variable. It seems to work as far as I can tell, but it would be great if you could give it a test drive. One other wishlist item would be to remove virtual buffers from the completion list as soon as the input string matches a normal buffer again, because the user deleted some chars from the input... Bye, Tassilo [-- Attachment #2: ido-virtual-buffers.patch --] [-- Type: text/x-patch, Size: 4814 bytes --] === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2010-05-27 07:08:37 +0000 +++ lisp/ChangeLog 2010-05-27 18:59:30 +0000 @@ -1,3 +1,14 @@ +2010-05-27 Tassilo Horn <tassilo@member.fsf.org> + + * ido.el (ido-exhibit, ido-buffer-internal) + (ido-toggle-virtual-buffers, ido-make-buffer-list) + (ido-buffer-internal, ido-exhibit, ido-read-internal): + ido-use-virtual-buffers now is a choice option with values 'never + (default), 'always, and 'auto. The latter means, show virtual + buffers if the current input doesn't match any existing buffer. + + Based on a patch by Leo <sdl.web@gmail.com>. + 2010-05-27 Kenichi Handa <handa@m17n.org> * language/hebrew.el (hebrew-shape-gstring): Check if a glyph === modified file 'lisp/ido.el' --- lisp/ido.el 2010-05-25 02:11:08 +0000 +++ lisp/ido.el 2010-05-27 18:58:16 +0000 @@ -774,8 +774,10 @@ :type '(repeat string) :group 'ido) -(defcustom ido-use-virtual-buffers nil - "If non-nil, refer to past buffers as well as existing ones. +(defcustom ido-use-virtual-buffers 'never + "If `always', refer to past buffers as well as existing ones. +If `auto', refer to past buffers only when the current input +doesn't match an existing buffer. Essentially it works as follows: Say you are visiting a file and the buffer gets cleaned up by mignight.el. Later, you want to switch to that buffer, but find it's no longer open. With @@ -785,11 +787,12 @@ to think less about whether recently opened files are still open or not. Most of the time you can quit Emacs, restart, and then switch to a file buffer that was previously open as if it still -were. - This feature relies upon the `recentf' package, which will be -enabled if this variable is configured to a non-nil value." +were. This feature relies upon the `recentf' package, which will +be enabled if this variable is configured to a non-nil value." :version "24.1" - :type 'boolean + :type '(choice (const always) + (const auto) + (const never)) :group 'ido) (defcustom ido-use-faces t @@ -1056,7 +1059,7 @@ (defvar ido-virtual-buffers nil "List of virtual buffers, that is, past visited files. This is a copy of `recentf-list', pared down and with faces applied. -Only used if `ido-use-virtual-buffers' is non-nil.") +Only used if `ido-use-virtual-buffers' is not `never'.") ;;; Variables with dynamic bindings. ;;; Declared here to keep the byte compiler quiet. @@ -1837,6 +1840,7 @@ ido-default-item ido-selected ido-final-text + ido-using-virtual-buffers (done nil) (icomplete-mode nil) ;; prevent icomplete starting up ;; Exported dynamic variables: @@ -2182,7 +2186,7 @@ (ido-directory-nonreadable nil) (ido-directory-too-big nil) (ido-use-virtual-buffers (if (eq method 'kill) - nil ;; Don't consider virtual buffers for killing + 'never ;; Don't consider virtual buffers for killing ido-use-virtual-buffers)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default @@ -2224,7 +2228,9 @@ (ido-visit-buffer buf method t))) ;; check for a virtual buffer reference - ((and ido-use-virtual-buffers ido-virtual-buffers + ((and (or (eq ido-use-virtual-buffers 'always) + (eq ido-use-virtual-buffers 'auto)) + ido-virtual-buffers (setq filename (assoc buf ido-virtual-buffers))) (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) @@ -2712,7 +2718,9 @@ See `ido-use-virtual-buffers' for explanation of virtual buffer." (interactive) (when (and ido-mode (eq ido-cur-item 'buffer)) - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) + (setq ido-use-virtual-buffers (if (eq ido-use-virtual-buffers 'never) + 'always + 'never)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) @@ -3403,7 +3411,9 @@ (when (and default (buffer-live-p (get-buffer default))) (setq ido-temp-list (cons default (delete default ido-temp-list)))) - (if ido-use-virtual-buffers + (if (or (eq ido-use-virtual-buffers 'always) + (and (eq ido-use-virtual-buffers 'auto) + (not ido-matches))) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) @@ -4465,6 +4475,15 @@ (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + (not ido-matches) + (not ido-using-virtual-buffers)) + (setq ido-text-init ido-text) + (setq ido-using-virtual-buffers t) + (setq ido-exit 'refresh) + (exit-minibuffer)) + (when (and ido-rescan (not ido-matches) ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-27 19:05 ` Tassilo Horn @ 2010-05-28 1:21 ` Leo 2010-05-28 1:45 ` Leo 0 siblings, 1 reply; 29+ messages in thread From: Leo @ 2010-05-28 1:21 UTC (permalink / raw) To: Tassilo Horn; +Cc: John Wiegley, Kim F. Storm, emacs-devel [-- Attachment #1: Type: text/plain, Size: 1469 bytes --] >> I think it is in the added code in ido-exhibit which is run in >> post-command-hook if I remember correctly. >> >> When your input doesn't match any (including virtual ones), the code >> in ido-exhibit tells ido (the big LOOP in ido-read-internal) to >> rebuild the buffer list and there isn't any match so it rebuild again >> and again. Go into a infinite loop. >> >> You could try creating a new let-bound variable to detect such a >> situation and avoid the infinite loop. > > Thanks for that. Here's a new patch which uses a new dynamic variable. > It seems to work as far as I can tell, but it would be great if you > could give it a test drive. > > One other wishlist item would be to remove virtual buffers from the > completion list as soon as the input string matches a normal buffer > again, because the user deleted some chars from the input... > > Bye, > Tassilo I slightly modified the patch and implemented the wishlist item. For buffers, if a let-bound variable can be added in ido-buffers-internal I usually avoid adding it in ido-read-internal. To remove virtual buffers as soon as input matches existing ones, the idea is to build a list of existing buffers (ignored buffers are not included) and then match the input against it in ido-exhibit. My testing is very brief though it seems working fine. Could you test it more thoroughly? Also remember to try the toggle virtual buffers key C-o too. Thanks. Leo [-- Attachment #2: ido-vbuffers-modified-by-leo.patch --] [-- Type: application/octet-stream, Size: 6344 bytes --] diff --git a/lisp/ido.el b/lisp/ido.el index cbcca62..1e470c8 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -775,8 +775,10 @@ can be completed using TAB, :type '(repeat string) :group 'ido) -(defcustom ido-use-virtual-buffers nil - "If non-nil, refer to past buffers as well as existing ones. +(defcustom ido-use-virtual-buffers 'never + "If `always', refer to past buffers as well as existing ones. +If `auto', refer to past buffers only when the current input +doesn't match an existing buffer. Essentially it works as follows: Say you are visiting a file and the buffer gets cleaned up by mignight.el. Later, you want to switch to that buffer, but find it's no longer open. With @@ -786,11 +788,12 @@ you select it, it opens the file back up again. This allows you to think less about whether recently opened files are still open or not. Most of the time you can quit Emacs, restart, and then switch to a file buffer that was previously open as if it still -were. - This feature relies upon the `recentf' package, which will be -enabled if this variable is configured to a non-nil value." +were. This feature relies upon the `recentf' package, which will +be enabled if this variable is configured to a non-nil value." :version "24.1" - :type 'boolean + :type '(choice (const always) + (const auto) + (const never)) :group 'ido) (defcustom ido-handle-duplicate-virtual-buffers 1 @@ -799,14 +802,6 @@ enabled if this variable is configured to a non-nil value." :type 'integer :group 'ido) -(defcustom ido-use-virtual-buffers-automatically nil - "Use virtual buffers automatically. -If non-nil, virtual buffers are automatically enabled when user -input does not match any existing buffers." - :version "24.1" - :type 'boolean - :group 'ido) - (defcustom ido-use-faces t "Non-nil means use ido faces to highlighting first match, only match and subdirs in the alternatives." @@ -1071,7 +1066,7 @@ Value is an integer which is number of chars to right of prompt.") (defvar ido-virtual-buffers nil "List of virtual buffers, that is, past visited files. This is a copy of `recentf-list', pared down and with faces applied. -Only used if `ido-use-virtual-buffers' is non-nil.") +Only used if `ido-use-virtual-buffers' is not `never'.") ;;; Variables with dynamic bindings. ;;; Declared here to keep the byte compiler quiet. @@ -1861,6 +1856,7 @@ If INITIAL is non-nil, it specifies the initial input string." (icomplete-mode nil) ;; prevent icomplete starting up ;; Exported dynamic variables: ido-cur-list + ido-existing-buffers ido-ignored-list (ido-rotate-temp nil) (ido-keep-item-list nil) @@ -1879,6 +1875,11 @@ If INITIAL is non-nil, it specifies the initial input string." (run-hooks 'ido-setup-hook) + (when (eq ido-cur-item 'buffer) + (setq ido-existing-buffers + (let (ido-virtual-buffers-enabled) + (ido-make-buffer-list nil)))) + (while (not done) (ido-trace "\n_LOOP_" ido-text-init) (setq ido-exit nil) @@ -2201,7 +2202,8 @@ If cursor is not at the end of the user input, move to end of input." (ido-current-directory nil) (ido-directory-nonreadable nil) (ido-directory-too-big nil) - (ido-use-virtual-buffers ido-use-virtual-buffers) + (ido-virtual-buffers-enabled (eq ido-use-virtual-buffers 'always)) + (ido-virtual-buffers-inhibit (not ido-virtual-buffers-enabled)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default require-match initial)) @@ -2242,7 +2244,9 @@ If cursor is not at the end of the user input, move to end of input." (ido-visit-buffer buf method t))) ;; check for a virtual buffer reference - ((and ido-use-virtual-buffers ido-virtual-buffers + ((and (or (eq ido-use-virtual-buffers 'always) + (eq ido-use-virtual-buffers 'auto)) + ido-virtual-buffers (setq filename (assoc buf ido-virtual-buffers))) (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) @@ -2736,7 +2740,8 @@ C-x C-f ... C-d enter `dired' on current directory." See `ido-use-virtual-buffers' for explanation of virtual buffer." (interactive) (when (and ido-mode (eq ido-cur-item 'buffer)) - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) + (setq ido-virtual-buffers-enabled + (not ido-virtual-buffers-enabled)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) @@ -3427,7 +3432,9 @@ for first matching file." (if default (setq ido-temp-list (cons default (delete default ido-temp-list)))) - (if ido-use-virtual-buffers + (if (or (eq ido-use-virtual-buffers 'always) + (and (boundp ido-virtual-buffers-enabled) + ido-virtual-buffers-enabled)) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) @@ -4510,14 +4517,32 @@ For details of keybindings, see `ido-find-file'." (setq ido-exit 'refresh) (exit-minibuffer))) - (when (and ido-use-virtual-buffers-automatically + (when (and (eq ido-use-virtual-buffers 'auto) (eq ido-cur-item 'buffer) (not ido-matches) - (not ido-use-virtual-buffers)) + ido-virtual-buffers-inhibit) (setq ido-text-init ido-text) - (setq ido-use-virtual-buffers t) - (setq ido-exit 'refresh) - (exit-minibuffer)) + (setq ido-virtual-buffers-enabled t) + (setq ido-virtual-buffers-inhibit nil) + (setq ido-exit 'refresh) + (exit-minibuffer)) + + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + ido-matches + ido-virtual-buffers-enabled + (not ido-virtual-buffers-inhibit)) + ;; protect ido-matches from being modified by ido-set-matches + (let ((ido-matches ido-matches)) + (let ((ido-cur-list ido-existing-buffers) + (ido-rotate ido-rotate)) + (ido-set-matches)) + (when ido-matches + (setq ido-virtual-buffers-enabled nil) + (setq ido-virtual-buffers-inhibit t) + (setq ido-text-init ido-text) + (setq ido-exit 'refresh) + (exit-minibuffer)))) (when (and ido-rescan ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 1:21 ` Leo @ 2010-05-28 1:45 ` Leo 2010-05-28 6:21 ` Tassilo Horn 0 siblings, 1 reply; 29+ messages in thread From: Leo @ 2010-05-28 1:45 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel On 28 May 2010 02:21, Leo <sdl.web@gmail.com> wrote: >>> I think it is in the added code in ido-exhibit which is run in >>> post-command-hook if I remember correctly. >>> >>> When your input doesn't match any (including virtual ones), the code >>> in ido-exhibit tells ido (the big LOOP in ido-read-internal) to >>> rebuild the buffer list and there isn't any match so it rebuild again >>> and again. Go into a infinite loop. >>> >>> You could try creating a new let-bound variable to detect such a >>> situation and avoid the infinite loop. >> >> Thanks for that. Here's a new patch which uses a new dynamic variable. >> It seems to work as far as I can tell, but it would be great if you >> could give it a test drive. >> >> One other wishlist item would be to remove virtual buffers from the >> completion list as soon as the input string matches a normal buffer >> again, because the user deleted some chars from the input... >> >> Bye, >> Tassilo > > I slightly modified the patch and implemented the wishlist item. > > For buffers, if a let-bound variable can be added in > ido-buffers-internal I usually avoid adding it in ido-read-internal. > > To remove virtual buffers as soon as input matches existing ones, the > idea is to build a list of existing buffers (ignored buffers are not > included) and then match the input against it in ido-exhibit. My > testing is very brief though it seems working fine. Could you test it > more thoroughly? Also remember to try the toggle virtual buffers key > C-o too. Thanks. > > Leo > The can be changed @@ -3427,7 +3431,9 @@ for first matching file." (if default (setq ido-temp-list (cons default (delete default ido-temp-list)))) - (if ido-use-virtual-buffers + (if (or (eq ido-use-virtual-buffers 'always) + (and (boundp ido-virtual-buffers-enabled) + ido-virtual-buffers-enabled)) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) to: @@ -2736,7 +2739,8 @@ C-x C-f ... C-d enter `dired' on current directory." See `ido-use-virtual-buffers' for explanation of virtual buffer." (interactive) (when (and ido-mode (eq ido-cur-item 'buffer)) - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) + (setq ido-virtual-buffers-enabled + (not ido-virtual-buffers-enabled)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) Leo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 1:45 ` Leo @ 2010-05-28 6:21 ` Tassilo Horn 2010-05-28 9:07 ` Leo 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-05-28 6:21 UTC (permalink / raw) To: Leo; +Cc: emacs-devel On Friday 28 May 2010 03:45:52 Leo wrote: Hi Leo, > > I slightly modified the patch and implemented the wishlist item. Cool! > > For buffers, if a let-bound variable can be added in > > ido-buffers-internal I usually avoid adding it in ido-read-internal. > > > > To remove virtual buffers as soon as input matches existing ones, the > > idea is to build a list of existing buffers (ignored buffers are not > > included) and then match the input against it in ido-exhibit. My > > testing is very brief though it seems working fine. Could you test it > > more thoroughly? Sure. > > Also remember to try the toggle virtual buffers key C-o too. Thanks. What do you mean with this one? > The can be changed > @@ -3427,7 +3431,9 @@ for first matching file." > (if default > (setq ido-temp-list > (cons default (delete default ido-temp-list)))) > - (if ido-use-virtual-buffers > + (if (or (eq ido-use-virtual-buffers 'always) > + (and (boundp ido-virtual-buffers-enabled) > + ido-virtual-buffers-enabled)) > (ido-add-virtual-buffers-to-list)) > (run-hooks 'ido-make-buffer-list-hook) > ido-temp-list)) > > > to: > > @@ -2736,7 +2739,8 @@ C-x C-f ... C-d enter `dired' on current directory." > See `ido-use-virtual-buffers' for explanation of virtual buffer." > (interactive) > (when (and ido-mode (eq ido-cur-item 'buffer)) > - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) > + (setq ido-virtual-buffers-enabled > + (not ido-virtual-buffers-enabled)) > (setq ido-text-init ido-text) > (setq ido-exit 'refresh) > (exit-minibuffer))) Both of these hunks are in your patch. I've read your mail as if I could simply delete the @@ -3427,7 +3431,9 @@ part from your patch. I did that, but then 3 out of 10 hunks fail... And if I try to apply the original patch without these modifications, then 4 out of 11 hunks fail. Could you please compile a new patch agains the current bzr trunk that I can test? Bye, Tassilo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 6:21 ` Tassilo Horn @ 2010-05-28 9:07 ` Leo 2010-05-28 9:26 ` Leo 2010-05-28 10:35 ` Juanma Barranquero 0 siblings, 2 replies; 29+ messages in thread From: Leo @ 2010-05-28 9:07 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 2471 bytes --] > > Also remember to try the toggle virtual buffers key C-o too. Thanks. > > What do you mean with this one? The C-o key when switching buffers toggles virtual buffers on and off so it it good make sure it is still working after the patch. >> The can be changed >> @@ -3427,7 +3431,9 @@ for first matching file." >> (if default >> (setq ido-temp-list >> (cons default (delete default ido-temp-list)))) >> - (if ido-use-virtual-buffers >> + (if (or (eq ido-use-virtual-buffers 'always) >> + (and (boundp ido-virtual-buffers-enabled) >> + ido-virtual-buffers-enabled)) >> (ido-add-virtual-buffers-to-list)) >> (run-hooks 'ido-make-buffer-list-hook) >> ido-temp-list)) >> >> >> to: >> >> @@ -2736,7 +2739,8 @@ C-x C-f ... C-d enter `dired' on current directory." >> See `ido-use-virtual-buffers' for explanation of virtual buffer." >> (interactive) >> (when (and ido-mode (eq ido-cur-item 'buffer)) >> - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) >> + (setq ido-virtual-buffers-enabled >> + (not ido-virtual-buffers-enabled)) >> (setq ido-text-init ido-text) >> (setq ido-exit 'refresh) >> (exit-minibuffer))) I copied the wrong text. Never mind. I have just recreated the patch against current trunk. The only bit that I am unsure is the deleted lines in the following hunk. i.e. if method is 'kill disregard virtual buffers. Seems like someone wants to work around a bug. But I don't know what it is so I didn't implement a similar logic in the added lines. Again my testing is very brief so it can break things. @@ -2181,9 +2191,8 @@ If cursor is not at the end of the user input, move to end of input." (ido-current-directory nil) (ido-directory-nonreadable nil) (ido-directory-too-big nil) - (ido-use-virtual-buffers (if (eq method 'kill) - nil ;; Don't consider virtual buffers for killing - ido-use-virtual-buffers)) + (ido-virtual-buffers-enabled (eq ido-use-virtual-buffers 'always)) + (ido-virtual-buffers-inhibit (not ido-virtual-buffers-enabled)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default require-match initial)) @@ -2224,7 +2233,8 @@ If cursor is not at the end of the user input, move to end of input." Best, Leo [-- Attachment #2: ido-vbuffers.diff --] [-- Type: application/octet-stream, Size: 5730 bytes --] diff --git a/lisp/ido.el b/lisp/ido.el index d34893d..8daef00 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -774,8 +774,10 @@ can be completed using TAB, :type '(repeat string) :group 'ido) -(defcustom ido-use-virtual-buffers nil - "If non-nil, refer to past buffers as well as existing ones. +(defcustom ido-use-virtual-buffers 'never + "If `always', refer to past buffers as well as existing ones. +If `auto', refer to past buffers only when the current input +doesn't match an existing buffer. Essentially it works as follows: Say you are visiting a file and the buffer gets cleaned up by mignight.el. Later, you want to switch to that buffer, but find it's no longer open. With @@ -785,11 +787,12 @@ you select it, it opens the file back up again. This allows you to think less about whether recently opened files are still open or not. Most of the time you can quit Emacs, restart, and then switch to a file buffer that was previously open as if it still -were. - This feature relies upon the `recentf' package, which will be -enabled if this variable is configured to a non-nil value." +were. This feature relies upon the `recentf' package, which will +be enabled if this variable is configured to a non-nil value." :version "24.1" - :type 'boolean + :type '(choice (const always) + (const auto) + (const never)) :group 'ido) (defcustom ido-use-faces t @@ -1056,7 +1059,7 @@ Value is an integer which is number of chars to right of prompt.") (defvar ido-virtual-buffers nil "List of virtual buffers, that is, past visited files. This is a copy of `recentf-list', pared down and with faces applied. -Only used if `ido-use-virtual-buffers' is non-nil.") +Only used if `ido-use-virtual-buffers' is not `never'.") ;;; Variables with dynamic bindings. ;;; Declared here to keep the byte compiler quiet. @@ -1841,6 +1844,7 @@ If INITIAL is non-nil, it specifies the initial input string." (icomplete-mode nil) ;; prevent icomplete starting up ;; Exported dynamic variables: ido-cur-list + ido-existing-buffers ido-ignored-list (ido-rotate-temp nil) (ido-keep-item-list nil) @@ -1859,6 +1863,12 @@ If INITIAL is non-nil, it specifies the initial input string." (run-hooks 'ido-setup-hook) + (when (eq ido-cur-item 'buffer) + (setq ido-existing-buffers + (let ((ido-process-ignore-lists nil) + ido-virtual-buffers-enabled) + (ido-make-buffer-list nil)))) + (while (not done) (ido-trace "\n_LOOP_" ido-text-init) (setq ido-exit nil) @@ -2181,9 +2191,8 @@ If cursor is not at the end of the user input, move to end of input." (ido-current-directory nil) (ido-directory-nonreadable nil) (ido-directory-too-big nil) - (ido-use-virtual-buffers (if (eq method 'kill) - nil ;; Don't consider virtual buffers for killing - ido-use-virtual-buffers)) + (ido-virtual-buffers-enabled (eq ido-use-virtual-buffers 'always)) + (ido-virtual-buffers-inhibit (not ido-virtual-buffers-enabled)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default require-match initial)) @@ -2224,7 +2233,8 @@ If cursor is not at the end of the user input, move to end of input." (ido-visit-buffer buf method t))) ;; check for a virtual buffer reference - ((and ido-use-virtual-buffers ido-virtual-buffers + ((and ido-virtual-buffers-enabled + ido-virtual-buffers (setq filename (assoc buf ido-virtual-buffers))) (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) @@ -2712,7 +2722,8 @@ C-x C-f ... C-d enter `dired' on current directory." See `ido-use-virtual-buffers' for explanation of virtual buffer." (interactive) (when (and ido-mode (eq ido-cur-item 'buffer)) - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) + (setq ido-virtual-buffers-enabled + (not ido-virtual-buffers-enabled)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) @@ -3403,7 +3414,9 @@ for first matching file." (when (and default (buffer-live-p (get-buffer default))) (setq ido-temp-list (cons default (delete default ido-temp-list)))) - (if ido-use-virtual-buffers + (if (or (eq ido-use-virtual-buffers 'always) + (and (boundp ido-virtual-buffers-enabled) + ido-virtual-buffers-enabled)) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) @@ -4465,6 +4478,33 @@ For details of keybindings, see `ido-find-file'." (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + (not ido-matches) + ido-virtual-buffers-inhibit) + (setq ido-text-init ido-text) + (setq ido-virtual-buffers-enabled t) + (setq ido-virtual-buffers-inhibit nil) + (setq ido-exit 'refresh) + (exit-minibuffer)) + + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + ido-matches + ido-virtual-buffers-enabled + (not ido-virtual-buffers-inhibit)) + ;; protect ido-matches from being modified by ido-set-matches + (let ((ido-matches ido-matches)) + (let ((ido-cur-list ido-existing-buffers) + (ido-rotate ido-rotate)) + (ido-set-matches)) + (when ido-matches + (setq ido-virtual-buffers-enabled nil) + (setq ido-virtual-buffers-inhibit t) + (setq ido-text-init ido-text) + (setq ido-exit 'refresh) + (exit-minibuffer)))) + (when (and ido-rescan (not ido-matches) ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 9:07 ` Leo @ 2010-05-28 9:26 ` Leo 2010-05-28 10:35 ` Juanma Barranquero 1 sibling, 0 replies; 29+ messages in thread From: Leo @ 2010-05-28 9:26 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel I forgot to take care of the compiler warnings. Please apply this patch on top of the last one. commit f6100b880cd559648d933a82fc21edf243d0c885 Author: Leo <sdl.web@gmail.com> Date: Fri May 28 10:22:59 2010 +0100 Quiet the compiler due to last change Modified lisp/ido.el diff --git a/lisp/ido.el b/lisp/ido.el index 4328166..3403822 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -1105,6 +1105,15 @@ Only used if `ido-use-virtual-buffers' is not `never'.") ;; Don't process ido-ignore- lists once. (defvar ido-process-ignore-lists-inhibit) +;; existing buffers including ignored ones when switching buffers in ido +(defvar ido-existing-buffers) + +;; ido virtual buffers are currently enabled +(defvar ido-virtual-buffers-enabled) + +;; stop ido virtual buffers from being added +(defvar ido-virtual-buffers-inhibit) + ;; Buffer from which ido was entered. (defvar ido-entry-buffer) ^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 9:07 ` Leo 2010-05-28 9:26 ` Leo @ 2010-05-28 10:35 ` Juanma Barranquero 2010-05-28 12:15 ` Leo 1 sibling, 1 reply; 29+ messages in thread From: Juanma Barranquero @ 2010-05-28 10:35 UTC (permalink / raw) To: Leo; +Cc: Tassilo Horn, emacs-devel On Fri, May 28, 2010 at 11:07, Leo <sdl.web@gmail.com> wrote: > The only bit that I am unsure is the deleted lines in the following > hunk. i.e. if method is 'kill disregard virtual buffers. Seems like > someone wants to work around a bug. But I don't know what it is so I > didn't implement a similar logic in the added lines. That was me. I doesn't help to show a list of nonexistent buffers when you want to kill an existent one, does it? The only way that would make sense is if killing a virtual buffer removed it from the list for good. Juanma ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 10:35 ` Juanma Barranquero @ 2010-05-28 12:15 ` Leo 2010-05-28 12:29 ` Tassilo Horn 0 siblings, 1 reply; 29+ messages in thread From: Leo @ 2010-05-28 12:15 UTC (permalink / raw) To: Juanma Barranquero; +Cc: Tassilo Horn, emacs-devel On 28 May 2010 11:35, Juanma Barranquero <lekktu@gmail.com> wrote: > On Fri, May 28, 2010 at 11:07, Leo <sdl.web@gmail.com> wrote: > >> The only bit that I am unsure is the deleted lines in the following >> hunk. i.e. if method is 'kill disregard virtual buffers. Seems like >> someone wants to work around a bug. But I don't know what it is so I >> didn't implement a similar logic in the added lines. > > That was me. > > I doesn't help to show a list of nonexistent buffers when you want to > kill an existent one, does it? The only way that would make sense is > if killing a virtual buffer removed it from the list for good. > > Juanma Thanks for this. I have incorporated your fix and the updated patch against trunk is available here: http://paste.lisp.org/display/105717#1. I am also using the patch myself so let's see if issues come up. Best wishes, Leo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 12:15 ` Leo @ 2010-05-28 12:29 ` Tassilo Horn 2010-05-29 14:15 ` Leo 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-05-28 12:29 UTC (permalink / raw) To: Leo; +Cc: Juanma Barranquero, emacs-devel [-- Attachment #1: Type: Text/Plain, Size: 377 bytes --] On Friday 28 May 2010 14:15:23 Leo wrote: Hi Leo! > Thanks for this. I have incorporated your fix and the updated patch > against trunk is available here: > http://paste.lisp.org/display/105717#1. I've applied it, and it seems to work like a charm. For the record, I attach it to this mail as well. So let's wait for your papers to arrive and then apply it. Bye, Tassilo [-- Attachment #2: ido-vbuffers-modified-by-leo.patch --] [-- Type: text/x-patch, Size: 5798 bytes --] === modified file 'lisp/ido.el' --- lisp/ido.el 2010-05-25 02:11:08 +0000 +++ lisp/ido.el 2010-05-28 12:26:03 +0000 @@ -774,8 +774,10 @@ :type '(repeat string) :group 'ido) -(defcustom ido-use-virtual-buffers nil - "If non-nil, refer to past buffers as well as existing ones. +(defcustom ido-use-virtual-buffers 'never + "If `always', refer to past buffers as well as existing ones. +If `auto', refer to past buffers only when the current input +doesn't match an existing buffer. Essentially it works as follows: Say you are visiting a file and the buffer gets cleaned up by mignight.el. Later, you want to switch to that buffer, but find it's no longer open. With @@ -785,11 +787,12 @@ to think less about whether recently opened files are still open or not. Most of the time you can quit Emacs, restart, and then switch to a file buffer that was previously open as if it still -were. - This feature relies upon the `recentf' package, which will be -enabled if this variable is configured to a non-nil value." +were. This feature relies upon the `recentf' package, which will +be enabled if this variable is configured to a non-nil value." :version "24.1" - :type 'boolean + :type '(choice (const always) + (const auto) + (const never)) :group 'ido) (defcustom ido-use-faces t @@ -1056,7 +1059,7 @@ (defvar ido-virtual-buffers nil "List of virtual buffers, that is, past visited files. This is a copy of `recentf-list', pared down and with faces applied. -Only used if `ido-use-virtual-buffers' is non-nil.") +Only used if `ido-use-virtual-buffers' is not `never'.") ;;; Variables with dynamic bindings. ;;; Declared here to keep the byte compiler quiet. @@ -1095,6 +1098,15 @@ ;; Don't process ido-ignore- lists once. (defvar ido-process-ignore-lists-inhibit) +;; existing buffers including ignored ones when switching buffers in ido +(defvar ido-existing-buffers) + +;; ido virtual buffers are currently enabled +(defvar ido-virtual-buffers-enabled) + +;; stop ido virtual buffers from being added +(defvar ido-virtual-buffers-inhibit) + ;; Buffer from which ido was entered. (defvar ido-entry-buffer) @@ -1841,6 +1853,7 @@ (icomplete-mode nil) ;; prevent icomplete starting up ;; Exported dynamic variables: ido-cur-list + ido-existing-buffers ido-ignored-list (ido-rotate-temp nil) (ido-keep-item-list nil) @@ -1859,6 +1872,12 @@ (run-hooks 'ido-setup-hook) + (when (eq ido-cur-item 'buffer) + (setq ido-existing-buffers + ;; ido-process-ignore-lists nil means not to ignore + (let (ido-process-ignore-lists ido-virtual-buffers-enabled) + (ido-make-buffer-list nil)))) + (while (not done) (ido-trace "\n_LOOP_" ido-text-init) (setq ido-exit nil) @@ -2181,9 +2200,11 @@ (ido-current-directory nil) (ido-directory-nonreadable nil) (ido-directory-too-big nil) - (ido-use-virtual-buffers (if (eq method 'kill) - nil ;; Don't consider virtual buffers for killing - ido-use-virtual-buffers)) + ;; when method is 'kill don't enable virtual buffers; this + ;; is the case when calling `idl-kill-buffer'. + (ido-virtual-buffers-enabled (and (eq ido-use-virtual-buffers 'always) + (not (eq method 'kill)))) + (ido-virtual-buffers-inhibit (not ido-virtual-buffers-enabled)) (require-match (confirm-nonexistent-file-or-buffer)) (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default require-match initial)) @@ -2224,7 +2245,8 @@ (ido-visit-buffer buf method t))) ;; check for a virtual buffer reference - ((and ido-use-virtual-buffers ido-virtual-buffers + ((and ido-virtual-buffers-enabled + ido-virtual-buffers (setq filename (assoc buf ido-virtual-buffers))) (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) @@ -2712,7 +2734,8 @@ See `ido-use-virtual-buffers' for explanation of virtual buffer." (interactive) (when (and ido-mode (eq ido-cur-item 'buffer)) - (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) + (setq ido-virtual-buffers-enabled + (not ido-virtual-buffers-enabled)) (setq ido-text-init ido-text) (setq ido-exit 'refresh) (exit-minibuffer))) @@ -3403,7 +3426,7 @@ (when (and default (buffer-live-p (get-buffer default))) (setq ido-temp-list (cons default (delete default ido-temp-list)))) - (if ido-use-virtual-buffers + (if (and (boundp ido-virtual-buffers-enabled) ido-virtual-buffers-enabled) (ido-add-virtual-buffers-to-list)) (run-hooks 'ido-make-buffer-list-hook) ido-temp-list)) @@ -4465,6 +4488,33 @@ (setq ido-exit 'refresh) (exit-minibuffer))) + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + (not ido-matches) + ido-virtual-buffers-inhibit) + (setq ido-text-init ido-text) + (setq ido-virtual-buffers-enabled t) + (setq ido-virtual-buffers-inhibit nil) + (setq ido-exit 'refresh) + (exit-minibuffer)) + + (when (and (eq ido-use-virtual-buffers 'auto) + (eq ido-cur-item 'buffer) + ido-matches + ido-virtual-buffers-enabled + (not ido-virtual-buffers-inhibit)) + ;; protect ido-matches from being modified by ido-set-matches + (let ((ido-matches ido-matches)) + (let ((ido-cur-list ido-existing-buffers) + (ido-rotate ido-rotate)) + (ido-set-matches)) + (when ido-matches + (setq ido-virtual-buffers-enabled nil) + (setq ido-virtual-buffers-inhibit t) + (setq ido-text-init ido-text) + (setq ido-exit 'refresh) + (exit-minibuffer)))) + (when (and ido-rescan (not ido-matches) ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-28 12:29 ` Tassilo Horn @ 2010-05-29 14:15 ` Leo 2010-06-01 23:54 ` Juanma Barranquero 0 siblings, 1 reply; 29+ messages in thread From: Leo @ 2010-05-29 14:15 UTC (permalink / raw) To: Tassilo Horn; +Cc: Juanma Barranquero, emacs-devel On 28 May 2010 13:29, Tassilo Horn <tassilo@member.fsf.org> wrote: > On Friday 28 May 2010 14:15:23 Leo wrote: > > Hi Leo! > >> Thanks for this. I have incorporated your fix and the updated patch >> against trunk is available here: >> http://paste.lisp.org/display/105717#1. > > I've applied it, and it seems to work like a charm. For the record, I > attach it to this mail as well. > > So let's wait for your papers to arrive and then apply it. > > Bye, > Tassilo Thanks for this. There could be some cases I miss that can trigger problems. For example I just found out ido-existing-buffers needs to be up-to-date otherwise the test will be incorrect and can trigger infinite loops. I will try to fix bugs as soon as they come up and keep the paste growing. Now we are at no 3: http://paste.lisp.org/display/105717#3 Hopefully at the time of merging it will be mature enough. Cheers, Leo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-05-29 14:15 ` Leo @ 2010-06-01 23:54 ` Juanma Barranquero 2010-06-02 3:28 ` Leo [not found] ` <AANLkTilMurdEZBA-kiWHlS9-r0VK6W5v@mail.gmail.com> 0 siblings, 2 replies; 29+ messages in thread From: Juanma Barranquero @ 2010-06-01 23:54 UTC (permalink / raw) To: Leo; +Cc: Tassilo Horn, emacs-devel On Sat, May 29, 2010 at 16:15, Leo <sdl.web@gmail.com> wrote: > I will try to fix bugs as soon as they come up and keep the paste > growing. Now we are at no 3: http://paste.lisp.org/display/105717#3 Value `never' is obvious, but non-documented. There is a typo idl -> ido in ;; is the case when calling `idl-kill-buffer'. `auto' would be more useful if tab completion showed past buffers. Now, if you don't remember the files you had open it can be difficult to type something to match them. Juanma ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-06-01 23:54 ` Juanma Barranquero @ 2010-06-02 3:28 ` Leo 2010-06-02 5:57 ` Juanma Barranquero [not found] ` <AANLkTilMurdEZBA-kiWHlS9-r0VK6W5v@mail.gmail.com> 1 sibling, 1 reply; 29+ messages in thread From: Leo @ 2010-06-02 3:28 UTC (permalink / raw) To: Juanma Barranquero; +Cc: Tassilo Horn, emacs-devel On 2 June 2010 00:54, Juanma Barranquero <lekktu@gmail.com> wrote: > On Sat, May 29, 2010 at 16:15, Leo <sdl.web@gmail.com> wrote: > >> I will try to fix bugs as soon as they come up and keep the paste >> growing. Now we are at no 3: http://paste.lisp.org/display/105717#3 > > Value `never' is obvious, but non-documented. I think we may need to change this variable to use nil and t instead, i.e. in the customisation interface, it shows never or always but in elisp it is nil or t. > There is a typo idl -> ido in > > ;; is the case when calling `idl-kill-buffer'. Thanks. Fixed. > `auto' would be more useful if tab completion showed past buffers. > Now, if you don't remember the files you had open it can be difficult > to type something to match them. I usually just use C-o to toggle virtual buffers. Is that sufficient? > Juanma Leo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-06-02 3:28 ` Leo @ 2010-06-02 5:57 ` Juanma Barranquero 2010-06-02 9:43 ` Leo 0 siblings, 1 reply; 29+ messages in thread From: Juanma Barranquero @ 2010-06-02 5:57 UTC (permalink / raw) To: Leo; +Cc: Tassilo Horn, emacs-devel On Wed, Jun 2, 2010 at 05:28, Leo <sdl.web@gmail.com> wrote: > I think we may need to change this variable to use nil and t instead, > i.e. in the customisation interface, it shows never or always but in > elisp it is nil or t. What about `auto', then? > I usually just use C-o to toggle virtual buffers. Is that sufficient? Yes, but it sort of defeats the need of having `auto' in the first place. Juanma ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-06-02 5:57 ` Juanma Barranquero @ 2010-06-02 9:43 ` Leo 0 siblings, 0 replies; 29+ messages in thread From: Leo @ 2010-06-02 9:43 UTC (permalink / raw) To: Juanma Barranquero; +Cc: Tassilo Horn, emacs-devel On 2 June 2010 06:57, Juanma Barranquero <lekktu@gmail.com> wrote: > On Wed, Jun 2, 2010 at 05:28, Leo <sdl.web@gmail.com> wrote: > >> I think we may need to change this variable to use nil and t instead, >> i.e. in the customisation interface, it shows never or always but in >> elisp it is nil or t. > > What about `auto', then? 'auto stays. I was talking about the other two values i.e. instead of inventing two symbols re-use nil and t. >> I usually just use C-o to toggle virtual buffers. Is that sufficient? > > Yes, but it sort of defeats the need of having `auto' in the first place. I just realise how few times I type TAB in ido, usually a few chars get me to the right choice. Anyway if it is considered favourable we definitely can add it. > Juanma Leo ^ permalink raw reply [flat|nested] 29+ messages in thread
[parent not found: <AANLkTilMurdEZBA-kiWHlS9-r0VK6W5v@mail.gmail.com>]
* Re: Concerning the new `ido-use-virtual-buffers' feature [not found] ` <AANLkTilMurdEZBA-kiWHlS9-r0VK6W5v@mail.gmail.com> @ 2011-10-16 10:06 ` Antoine Levitt 2013-07-06 12:57 ` Leo Liu 0 siblings, 1 reply; 29+ messages in thread From: Antoine Levitt @ 2011-10-16 10:06 UTC (permalink / raw) To: emacs-devel Leo <sdl.web <at> gmail.com> writes: > > On 2 June 2010 00:54, Juanma Barranquero <lekktu <at> gmail.com> wrote: > > On Sat, May 29, 2010 at 16:15, Leo <sdl.web <at> gmail.com> wrote: > > > >> I will try to fix bugs as soon as they come up and keep the paste > >> growing. Now we are at no 3: http://paste.lisp.org/display/105717#3 Hi guys, Any progress on this 'auto thing? No patch has still hit trunk. ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2011-10-16 10:06 ` Antoine Levitt @ 2013-07-06 12:57 ` Leo Liu 0 siblings, 0 replies; 29+ messages in thread From: Leo Liu @ 2013-07-06 12:57 UTC (permalink / raw) To: Antoine Levitt; +Cc: emacs-devel On 2011-10-16 18:06 +0800, Antoine Levitt wrote: > Hi guys, > > Any progress on this 'auto thing? No patch has still hit trunk. Sorry for the long delay. I have reviewed and simplified the patch and committed it to trunk in revno 113301. Let me know if you may have any comments. Thanks, Leo ^ permalink raw reply [flat|nested] 29+ messages in thread
[parent not found: <201006020842.48913.tassilo@member.fsf.org>]
[parent not found: <AANLkTikTDRtnbzNHTzVlMvHyl0pDHuhpQLu5k8Il4vP0@mail.gmail.com>]
* Re: Concerning the new `ido-use-virtual-buffers' feature [not found] ` <AANLkTikTDRtnbzNHTzVlMvHyl0pDHuhpQLu5k8Il4vP0@mail.gmail.com> @ 2010-06-02 8:29 ` Tassilo Horn 2010-06-02 9:28 ` Juanma Barranquero 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-06-02 8:29 UTC (permalink / raw) To: Juanma Barranquero; +Cc: Leo, emacs-devel On Wednesday 02 June 2010 09:23:50 you wrote: Sorry for removing the list and Leo on my last reply to Juanma. > > I don't think so. `C-x b foo RET' is in my muscle memory, and when > > I use `C-x b' I know what buffer/file I want to open. I don't want > > to worry about if it is an open buffer or a recent file. With `C-o' > > toggling only, I always have know if that file is already visited in > > a buffer. > > If you always remember the file you want to edit, then yes. My point > is that if you don't remember (that happens to me a lot, I remember > what I was doing but I forget the file name), having to do C-o defeats > having auto. So you would have no virtual buffers by default and just enable them when you don't remember the file name? So why not enable them by default? For me, the reason to use ido is because substring matching is very quick: I type C-x b foo RET without even looking at the completions. In 99% of all cases, it brings me to the right buffer, unless virtual buffers are enabled. In that case, it will bring me to "foo.aux" (recent file I had a look at some time ago) instead of "foo.tex" (currently open for editing). The 'auto value enables that DWIM behavior also for recent files for me. So when I type C-x b foo.a RET, I really want to open "foo.aux", and still I don't have to care about if it is really open. > Though the real fix, as I proposed, is having <tab> completion enable > the virtual buffers temporarily. From my point of view, that's not as good as the 'auto value, at least in my usecase, because then I have to mentally distinguish between open buffers and recent files. So how about this: <tab> toggles virtual buffers temporarily, and if `ido-use-virtual-buffers' is non-nil, then "no match" enables them, too. So basically, `ido-use-virtual-buffers' non-nil does what 'auto does with Leo's patch now. There's no way to have virtual buffers per default, which is pretty useless IMHO anyway. I think <tab> should not only enable but toggle, because else I could not create a new buffer "foo.a" if `ido-use-virtual-buffers' is non-nil. What do you think? Bye, Tassilo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-06-02 8:29 ` Tassilo Horn @ 2010-06-02 9:28 ` Juanma Barranquero 2010-06-02 9:55 ` Tassilo Horn 0 siblings, 1 reply; 29+ messages in thread From: Juanma Barranquero @ 2010-06-02 9:28 UTC (permalink / raw) To: Tassilo Horn; +Cc: Leo, emacs-devel On Wed, Jun 2, 2010 at 10:29, Tassilo Horn <tassilo@member.fsf.org> wrote: > So you would have no virtual buffers by default and just enable them > when you don't remember the file name? So why not enable them by > default? I like the virtual buffers feature, but most of the time I switch to an existing bufer, so having a dozen virtual buffers in the list is just cruft. `auto' seems like the answer... except when I can not remember how the file was named. > So how about this: <tab> toggles virtual buffers temporarily, and if > `ido-use-virtual-buffers' is non-nil, then "no match" enables them, too. Similar to what I'm proposing, that is, that in `auto' mode, after "C-x b", <TAB> should temporarily switch to `always'. > So basically, `ido-use-virtual-buffers' non-nil does what 'auto does > with Leo's patch now. There's no way to have virtual buffers per > default, which is pretty useless IMHO anyway. Difficult to say. I wouldn't be surprised to find people who wants the virtual buffers to be shown all the time. > I think <tab> should not only enable but toggle, because else I could > not create a new buffer "foo.a" if `ido-use-virtual-buffers' is non-nil. C-o already toggles it, i.e., C-x b foo.a C-o <RET> <RET> Juanma ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-06-02 9:28 ` Juanma Barranquero @ 2010-06-02 9:55 ` Tassilo Horn 2010-06-02 10:27 ` Juanma Barranquero 0 siblings, 1 reply; 29+ messages in thread From: Tassilo Horn @ 2010-06-02 9:55 UTC (permalink / raw) To: Juanma Barranquero; +Cc: Leo, emacs-devel On Wednesday 02 June 2010 11:28:34 Juanma Barranquero wrote: > I like the virtual buffers feature, but most of the time I switch to > an existing bufer, so having a dozen virtual buffers in the list is > just cruft. `auto' seems like the answer... except when I can not > remember how the file was named. Exactly, and then you can hit <tab>. > > So how about this: <tab> toggles virtual buffers temporarily, and if > > `ido-use-virtual-buffers' is non-nil, then "no match" enables them, > > too. > > Similar to what I'm proposing, that is, that in `auto' mode, after > "C-x b", <TAB> should temporarily switch to `always'. Ah, Leo was the one to change the values back to nil/non-nil back again. IMO, that fits well with your tab completion idea. If you don't remember the name, C-x b <tab> will enable the virtual buffers temporarily. `C-x b foobar' with no match and ido-use-virtual-buffers set to non-nil will also enable them temporarily. I think, that fits our usecases very good. > > So basically, `ido-use-virtual-buffers' non-nil does what 'auto does > > with Leo's patch now. There's no way to have virtual buffers per > > default, which is pretty useless IMHO anyway. > > Difficult to say. I wouldn't be surprised to find people who wants the > virtual buffers to be shown all the time. Sure, but as this feature has never been in a released emacs version, now is the time to come up with something that fits at least most usecases. And the <tab> combined with the "auto if ido-use-virtual-buffers in non-nil" idea fits the "I want to be quick/DWIM" as well as the "I want to see what I have" usecases well. Till now, I cannot imagine any other usecase... > > I think <tab> should not only enable but toggle, because else I could > > not create a new buffer "foo.a" if `ido-use-virtual-buffers' is non-nil. > > C-o already toggles it, i.e., C-x b foo.a C-o <RET> <RET> Yes, but <tab> is more convenient, and the behavior I tried to summarize hopefully tries to minimize the need for toggling, i.e. you only need it if you want to see all recent files or you want to create a new buffer which is not associated to a recent file with similar name. Bye, Tassilo ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Concerning the new `ido-use-virtual-buffers' feature 2010-06-02 9:55 ` Tassilo Horn @ 2010-06-02 10:27 ` Juanma Barranquero 0 siblings, 0 replies; 29+ messages in thread From: Juanma Barranquero @ 2010-06-02 10:27 UTC (permalink / raw) To: Tassilo Horn; +Cc: Leo, emacs-devel On Wed, Jun 2, 2010 at 11:55, Tassilo Horn <tassilo@member.fsf.org> wrote: > Exactly, and then you can hit <tab>. Yes, that's what I want. > Ah, Leo was the one to change the values back to nil/non-nil back > again. ?? IMO, that fits well with your tab completion idea. > If you don't remember the name, C-x b <tab> will enable the virtual > buffers temporarily. `C-x b foobar' with no match and > ido-use-virtual-buffers set to non-nil will also enable them > temporarily. > > I think, that fits our usecases very good. Let's give it a try, as soon as someone :-) implements it... > Yes, but <tab> is more convenient Agreed. Juanma ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2013-07-06 12:57 UTC | newest] Thread overview: 29+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-05-26 10:14 Concerning the new `ido-use-virtual-buffers' feature Tassilo Horn 2010-05-26 20:59 ` John Wiegley 2010-05-27 6:54 ` Tassilo Horn 2010-05-27 6:57 ` John Wiegley 2010-05-27 8:10 ` Tassilo Horn 2010-05-27 8:26 ` John Wiegley -- strict thread matches above, loose matches on Subject: below -- 2010-05-27 9:56 Leo 2010-05-27 10:57 ` Tassilo Horn 2010-05-27 18:01 ` Leo 2010-05-27 19:05 ` Tassilo Horn 2010-05-28 1:21 ` Leo 2010-05-28 1:45 ` Leo 2010-05-28 6:21 ` Tassilo Horn 2010-05-28 9:07 ` Leo 2010-05-28 9:26 ` Leo 2010-05-28 10:35 ` Juanma Barranquero 2010-05-28 12:15 ` Leo 2010-05-28 12:29 ` Tassilo Horn 2010-05-29 14:15 ` Leo 2010-06-01 23:54 ` Juanma Barranquero 2010-06-02 3:28 ` Leo 2010-06-02 5:57 ` Juanma Barranquero 2010-06-02 9:43 ` Leo [not found] ` <AANLkTilMurdEZBA-kiWHlS9-r0VK6W5v@mail.gmail.com> 2011-10-16 10:06 ` Antoine Levitt 2013-07-06 12:57 ` Leo Liu [not found] ` <201006020842.48913.tassilo@member.fsf.org> [not found] ` <AANLkTikTDRtnbzNHTzVlMvHyl0pDHuhpQLu5k8Il4vP0@mail.gmail.com> 2010-06-02 8:29 ` Tassilo Horn 2010-06-02 9:28 ` Juanma Barranquero 2010-06-02 9:55 ` Tassilo Horn 2010-06-02 10:27 ` Juanma Barranquero
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.