emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113301: * ido.el (ido-use-virtual-buffers): Allow n


From: Leo Liu
Subject: [Emacs-diffs] trunk r113301: * ido.el (ido-use-virtual-buffers): Allow new value 'auto.
Date: Sat, 06 Jul 2013 12:40:41 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113301
revision-id: address@hidden
parent: address@hidden
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Sat 2013-07-06 20:37:12 +0800
message:
  * ido.el (ido-use-virtual-buffers): Allow new value 'auto.
  (ido-enable-virtual-buffers): New variable.
  (ido-buffer-internal, ido-toggle-virtual-buffers)
  (ido-make-buffer-list): Use it.
  (ido-exhibit): Support turning on and off virtual buffers
  automatically.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/ido.el                    ido.el-20091113204419-o5vbwnq5f7feedwu-2430
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-07-06 09:35:37 +0000
+++ b/lisp/ChangeLog    2013-07-06 12:37:12 +0000
@@ -1,3 +1,12 @@
+2013-07-06  Leo Liu  <address@hidden>
+
+       * ido.el (ido-use-virtual-buffers): Allow new value 'auto.
+       (ido-enable-virtual-buffers): New variable.
+       (ido-buffer-internal, ido-toggle-virtual-buffers)
+       (ido-make-buffer-list): Use it.
+       (ido-exhibit): Support turning on and off virtual buffers
+       automatically.
+
 2013-07-06  Juanma Barranquero  <address@hidden>
 
        * simple.el (alternatives-define): New macro.

=== modified file 'lisp/ido.el'
--- a/lisp/ido.el       2013-07-03 03:01:34 +0000
+++ b/lisp/ido.el       2013-07-06 12:37:12 +0000
@@ -782,21 +782,29 @@
   :group 'ido)
 
 (defcustom ido-use-virtual-buffers nil
-  "If non-nil, refer to past buffers as well as existing ones.
+  "Specify how vritual buffers should be used.
+The value can be one of the following:
+
+  nil:  No virtual buffers are used.
+  auto: Use virtual bufferw when the current input matches no
+        existing buffers.
+  t:    Always use virtual buffers.
+
 Essentially it works as follows: Say you are visiting a file and
 the buffer gets cleaned up by midnight.el.  Later, you want to
-switch to that buffer, but find it's no longer open.  With
-virtual buffers enabled, the buffer name stays in the buffer
-list (using the `ido-virtual' face, and always at the end), and if
-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."
-  :version "24.1"
-  :type 'boolean
+switch to that buffer, but find it's no longer open.  With virtual
+buffers enabled, the buffer name stays in the buffer list (using
+the `ido-virtual' face, and always at the end), and if 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."
+  :version "24.4"
+  :type '(choice (const :tag "Always" t)
+                (const :tag "Automatic" auto)
+                (const :tag "Never" nil))
   :group 'ido)
 
 (defcustom ido-use-faces t
@@ -1103,6 +1111,9 @@
 ;; Don't process ido-ignore- lists once.
 (defvar ido-process-ignore-lists-inhibit)
 
+;; Is ido using virtual buffers?
+(defvar ido-enable-virtual-buffers)
+
 ;; Buffer from which ido was entered.
 (defvar ido-entry-buffer)
 
@@ -2202,7 +2213,8 @@
           (ido-current-directory nil)
           (ido-directory-nonreadable nil)
           (ido-directory-too-big nil)
-          (ido-use-virtual-buffers ido-use-virtual-buffers)
+          (ido-enable-virtual-buffers (and ido-use-virtual-buffers
+                                           (not (eq ido-use-virtual-buffers 
'auto))))
           (require-match (confirm-nonexistent-file-or-buffer))
           (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 
'ido-buffer-history default
                                   require-match initial))
@@ -2243,7 +2255,8 @@
          (ido-visit-buffer buf method t)))
 
        ;; check for a virtual buffer reference
-       ((and ido-use-virtual-buffers ido-virtual-buffers
+       ((and ido-enable-virtual-buffers
+            ido-virtual-buffers
             (setq filename (assoc buf ido-virtual-buffers)))
        (ido-visit-buffer (find-file-noselect (cdr filename)) method t))
 
@@ -2734,7 +2747,11 @@
 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-enable-virtual-buffers
+         (if ido-enable-virtual-buffers
+             nil
+           ;; Use `always' instead of t for `ido-exhibit'.
+           'always))
     (setq ido-text-init ido-text)
     (setq ido-exit 'refresh)
     (exit-minibuffer)))
@@ -3427,9 +3444,9 @@
        (nconc ido-temp-list ido-current-buffers)
       (setq ido-temp-list ido-current-buffers))
     (if default
-        (setq ido-temp-list
-              (cons default (delete default ido-temp-list))))
-    (if ido-use-virtual-buffers
+       (setq ido-temp-list
+             (cons default (delete default ido-temp-list))))
+    (if (bound-and-true-p ido-enable-virtual-buffers)
        (ido-add-virtual-buffers-to-list))
     (run-hooks 'ido-make-buffer-list-hook)
     ido-temp-list))
@@ -4477,6 +4494,27 @@
          (setq ido-exit 'refresh)
          (exit-minibuffer))
 
+       (when (and (boundp 'ido-enable-virtual-buffers)
+                  (not (eq ido-enable-virtual-buffers 'always))
+                  (eq ido-cur-item 'buffer)
+                  (eq ido-use-virtual-buffers 'auto))
+
+         (when (and (not ido-enable-virtual-buffers)
+                    (not ido-matches))
+           (setq ido-text-init ido-text)
+           (setq ido-enable-virtual-buffers t)
+           (setq ido-exit 'refresh)
+           (exit-minibuffer))
+
+         ;; If input matches real buffers turn off virtual buffers.
+         (when (and ido-enable-virtual-buffers
+                    ido-matches
+                    (ido-set-matches-1 (ido-make-buffer-list-1)))
+           (setq ido-enable-virtual-buffers nil)
+           (setq ido-text-init ido-text)
+           (setq ido-exit 'refresh)
+           (exit-minibuffer)))
+
        (when (and (not ido-matches)
                   (not ido-directory-nonreadable)
                   (not ido-directory-too-big)


reply via email to

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