aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/ido.el76
2 files changed, 66 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 901e582d15e..cd7859a940a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12013-07-06 Leo Liu <sdl.web@gmail.com>
2
3 * ido.el (ido-use-virtual-buffers): Allow new value 'auto.
4 (ido-enable-virtual-buffers): New variable.
5 (ido-buffer-internal, ido-toggle-virtual-buffers)
6 (ido-make-buffer-list): Use it.
7 (ido-exhibit): Support turning on and off virtual buffers
8 automatically.
9
12013-07-06 Juanma Barranquero <lekktu@gmail.com> 102013-07-06 Juanma Barranquero <lekktu@gmail.com>
2 11
3 * simple.el (alternatives-define): New macro. 12 * simple.el (alternatives-define): New macro.
diff --git a/lisp/ido.el b/lisp/ido.el
index bfa515ba26c..f695ec117f1 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -782,21 +782,29 @@ remaining completion. If absent, elements 5 and 6 are used instead."
782 :group 'ido) 782 :group 'ido)
783 783
784(defcustom ido-use-virtual-buffers nil 784(defcustom ido-use-virtual-buffers nil
785 "If non-nil, refer to past buffers as well as existing ones. 785 "Specify how vritual buffers should be used.
786The value can be one of the following:
787
788 nil: No virtual buffers are used.
789 auto: Use virtual bufferw when the current input matches no
790 existing buffers.
791 t: Always use virtual buffers.
792
786Essentially it works as follows: Say you are visiting a file and 793Essentially it works as follows: Say you are visiting a file and
787the buffer gets cleaned up by midnight.el. Later, you want to 794the buffer gets cleaned up by midnight.el. Later, you want to
788switch to that buffer, but find it's no longer open. With 795switch to that buffer, but find it's no longer open. With virtual
789virtual buffers enabled, the buffer name stays in the buffer 796buffers enabled, the buffer name stays in the buffer list (using
790list (using the `ido-virtual' face, and always at the end), and if 797the `ido-virtual' face, and always at the end), and if you select
791you select it, it opens the file back up again. This allows you 798it, it opens the file back up again. This allows you to think
792to think less about whether recently opened files are still open 799less about whether recently opened files are still open or not.
793or not. Most of the time you can quit Emacs, restart, and then 800Most of the time you can quit Emacs, restart, and then switch to
794switch to a file buffer that was previously open as if it still 801a file buffer that was previously open as if it still were. This
795were. 802feature relies upon the `recentf' package, which will be enabled
796 This feature relies upon the `recentf' package, which will be 803if this variable is configured to a non-nil value."
797enabled if this variable is configured to a non-nil value." 804 :version "24.4"
798 :version "24.1" 805 :type '(choice (const :tag "Always" t)
799 :type 'boolean 806 (const :tag "Automatic" auto)
807 (const :tag "Never" nil))
800 :group 'ido) 808 :group 'ido)
801 809
802(defcustom ido-use-faces t 810(defcustom ido-use-faces t
@@ -1103,6 +1111,9 @@ Only used if `ido-use-virtual-buffers' is non-nil.")
1103;; Don't process ido-ignore- lists once. 1111;; Don't process ido-ignore- lists once.
1104(defvar ido-process-ignore-lists-inhibit) 1112(defvar ido-process-ignore-lists-inhibit)
1105 1113
1114;; Is ido using virtual buffers?
1115(defvar ido-enable-virtual-buffers)
1116
1106;; Buffer from which ido was entered. 1117;; Buffer from which ido was entered.
1107(defvar ido-entry-buffer) 1118(defvar ido-entry-buffer)
1108 1119
@@ -2202,7 +2213,8 @@ If cursor is not at the end of the user input, move to end of input."
2202 (ido-current-directory nil) 2213 (ido-current-directory nil)
2203 (ido-directory-nonreadable nil) 2214 (ido-directory-nonreadable nil)
2204 (ido-directory-too-big nil) 2215 (ido-directory-too-big nil)
2205 (ido-use-virtual-buffers ido-use-virtual-buffers) 2216 (ido-enable-virtual-buffers (and ido-use-virtual-buffers
2217 (not (eq ido-use-virtual-buffers 'auto))))
2206 (require-match (confirm-nonexistent-file-or-buffer)) 2218 (require-match (confirm-nonexistent-file-or-buffer))
2207 (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default 2219 (buf (ido-read-internal 'buffer (or prompt "Buffer: ") 'ido-buffer-history default
2208 require-match initial)) 2220 require-match initial))
@@ -2243,7 +2255,8 @@ If cursor is not at the end of the user input, move to end of input."
2243 (ido-visit-buffer buf method t))) 2255 (ido-visit-buffer buf method t)))
2244 2256
2245 ;; check for a virtual buffer reference 2257 ;; check for a virtual buffer reference
2246 ((and ido-use-virtual-buffers ido-virtual-buffers 2258 ((and ido-enable-virtual-buffers
2259 ido-virtual-buffers
2247 (setq filename (assoc buf ido-virtual-buffers))) 2260 (setq filename (assoc buf ido-virtual-buffers)))
2248 (ido-visit-buffer (find-file-noselect (cdr filename)) method t)) 2261 (ido-visit-buffer (find-file-noselect (cdr filename)) method t))
2249 2262
@@ -2734,7 +2747,11 @@ C-x C-f ... C-d enter `dired' on current directory."
2734See `ido-use-virtual-buffers' for explanation of virtual buffer." 2747See `ido-use-virtual-buffers' for explanation of virtual buffer."
2735 (interactive) 2748 (interactive)
2736 (when (and ido-mode (eq ido-cur-item 'buffer)) 2749 (when (and ido-mode (eq ido-cur-item 'buffer))
2737 (setq ido-use-virtual-buffers (not ido-use-virtual-buffers)) 2750 (setq ido-enable-virtual-buffers
2751 (if ido-enable-virtual-buffers
2752 nil
2753 ;; Use `always' instead of t for `ido-exhibit'.
2754 'always))
2738 (setq ido-text-init ido-text) 2755 (setq ido-text-init ido-text)
2739 (setq ido-exit 'refresh) 2756 (setq ido-exit 'refresh)
2740 (exit-minibuffer))) 2757 (exit-minibuffer)))
@@ -3427,9 +3444,9 @@ it is put to the start of the list."
3427 (nconc ido-temp-list ido-current-buffers) 3444 (nconc ido-temp-list ido-current-buffers)
3428 (setq ido-temp-list ido-current-buffers)) 3445 (setq ido-temp-list ido-current-buffers))
3429 (if default 3446 (if default
3430 (setq ido-temp-list 3447 (setq ido-temp-list
3431 (cons default (delete default ido-temp-list)))) 3448 (cons default (delete default ido-temp-list))))
3432 (if ido-use-virtual-buffers 3449 (if (bound-and-true-p ido-enable-virtual-buffers)
3433 (ido-add-virtual-buffers-to-list)) 3450 (ido-add-virtual-buffers-to-list))
3434 (run-hooks 'ido-make-buffer-list-hook) 3451 (run-hooks 'ido-make-buffer-list-hook)
3435 ido-temp-list)) 3452 ido-temp-list))
@@ -4477,6 +4494,27 @@ For details of keybindings, see `ido-find-file'."
4477 (setq ido-exit 'refresh) 4494 (setq ido-exit 'refresh)
4478 (exit-minibuffer)) 4495 (exit-minibuffer))
4479 4496
4497 (when (and (boundp 'ido-enable-virtual-buffers)
4498 (not (eq ido-enable-virtual-buffers 'always))
4499 (eq ido-cur-item 'buffer)
4500 (eq ido-use-virtual-buffers 'auto))
4501
4502 (when (and (not ido-enable-virtual-buffers)
4503 (not ido-matches))
4504 (setq ido-text-init ido-text)
4505 (setq ido-enable-virtual-buffers t)
4506 (setq ido-exit 'refresh)
4507 (exit-minibuffer))
4508
4509 ;; If input matches real buffers turn off virtual buffers.
4510 (when (and ido-enable-virtual-buffers
4511 ido-matches
4512 (ido-set-matches-1 (ido-make-buffer-list-1)))
4513 (setq ido-enable-virtual-buffers nil)
4514 (setq ido-text-init ido-text)
4515 (setq ido-exit 'refresh)
4516 (exit-minibuffer)))
4517
4480 (when (and (not ido-matches) 4518 (when (and (not ido-matches)
4481 (not ido-directory-nonreadable) 4519 (not ido-directory-nonreadable)
4482 (not ido-directory-too-big) 4520 (not ido-directory-too-big)