unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo <sdl.web@gmail.com>
To: Tassilo Horn <tassilo@member.fsf.org>
Cc: emacs-devel@gnu.org
Subject: Re: Concerning the new `ido-use-virtual-buffers' feature
Date: Fri, 28 May 2010 10:07:47 +0100	[thread overview]
Message-ID: <AANLkTik_S2CaqNDu1HV5qv_gnTQ4IYMDE-dhiJB33rSL@mail.gmail.com> (raw)
In-Reply-To: <201005280821.31181.tassilo@member.fsf.org>

[-- 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)

  reply	other threads:[~2010-05-28  9:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27  9:56 Concerning the new `ido-use-virtual-buffers' feature 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 [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2010-05-26 10:14 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTik_S2CaqNDu1HV5qv_gnTQ4IYMDE-dhiJB33rSL@mail.gmail.com \
    --to=sdl.web@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=tassilo@member.fsf.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).