Commit 9caf8a8f authored by Juanma Barranquero's avatar Juanma Barranquero
Browse files

Enable recentf-mode if using virtual buffers.

* ido.el (recentf-list): Declare for byte-compiler.
  (ido-virtual-buffers): Move up to silence byte-compiler.  Add docstring.
  (ido-make-buffer-list): Simplify.
  (ido-add-virtual-buffers-to-list): Simplify.  Enable recentf-mode.
parent 5a97d2da
2010-04-06 Juanma Barranquero <lekktu@gmail.com>
Enable recentf-mode if using virtual buffers.
* ido.el (recentf-list): Declare for byte-compiler.
(ido-virtual-buffers): Move up to silence byte-compiler. Add docstring.
(ido-make-buffer-list): Simplify.
(ido-add-virtual-buffers-to-list): Simplify. Enable recentf-mode.
2010-04-05 Juri Linkov <juri@jurta.org> 2010-04-05 Juri Linkov <juri@jurta.org>
Scrolling commands which scroll a line instead of full screen. Scrolling commands which scroll a line instead of full screen.
......
...@@ -323,6 +323,7 @@ ...@@ -323,6 +323,7 @@
;;; Code: ;;; Code:
(defvar cua-inhibit-cua-keys) (defvar cua-inhibit-cua-keys)
(defvar recentf-list)
;;; User Variables ;;; User Variables
;; ;;
...@@ -1041,6 +1042,11 @@ so that it doesn't interfere with other minibuffer usage.") ...@@ -1041,6 +1042,11 @@ so that it doesn't interfere with other minibuffer usage.")
"Non-nil means to explicitly cursor on entry to minibuffer. "Non-nil means to explicitly cursor on entry to minibuffer.
Value is an integer which is number of chars to right of prompt.") 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.")
;;; Variables with dynamic bindings. ;;; Variables with dynamic bindings.
;;; Declared here to keep the byte compiler quiet. ;;; Declared here to keep the byte compiler quiet.
...@@ -3366,37 +3372,30 @@ for first matching file." ...@@ -3366,37 +3372,30 @@ for first matching file."
(if ido-temp-list (if ido-temp-list
(nconc ido-temp-list ido-current-buffers) (nconc ido-temp-list ido-current-buffers)
(setq ido-temp-list ido-current-buffers)) (setq ido-temp-list ido-current-buffers))
(if (and default (buffer-live-p (get-buffer default))) (when (and default (buffer-live-p (get-buffer default)))
(progn (setq ido-temp-list
(setq ido-temp-list (cons default (delete default ido-temp-list))))
(delete default ido-temp-list))
(setq ido-temp-list
(cons default ido-temp-list))))
(if ido-use-virtual-buffers (if ido-use-virtual-buffers
(ido-add-virtual-buffers-to-list)) (ido-add-virtual-buffers-to-list))
(run-hooks 'ido-make-buffer-list-hook) (run-hooks 'ido-make-buffer-list-hook)
ido-temp-list)) ido-temp-list))
(defvar ido-virtual-buffers nil)
(defun ido-add-virtual-buffers-to-list () (defun ido-add-virtual-buffers-to-list ()
"Add recently visited files, and bookmark files, to the buffer list. "Add recently visited files, and bookmark files, to the buffer list.
This is to make them appear as if they were \"virtual buffers\"." This is to make them appear as if they were \"virtual buffers\"."
;; If no buffers matched, and virtual buffers are being used, then ;; If no buffers matched, and virtual buffers are being used, then
;; consult the list of past visited files, to see if we can find ;; consult the list of past visited files, to see if we can find
;; the file which the user might thought was still open. ;; the file which the user might thought was still open.
(unless recentf-mode (recentf-mode 1))
(setq ido-virtual-buffers nil) (setq ido-virtual-buffers nil)
(let ((head recentf-list) name) (let (name)
(while head (dolist (head recentf-list)
(if (and (setq name (file-name-nondirectory (car head))) (and (setq name (file-name-nondirectory head))
(null (get-file-buffer (car head))) (null (get-file-buffer head))
(not (assoc name ido-virtual-buffers)) (not (assoc name ido-virtual-buffers))
(not (ido-ignore-item-p name ido-ignore-buffers)) (not (ido-ignore-item-p name ido-ignore-buffers))
;;(file-exists-p (car head)) ;;(file-exists-p head)
) (push (cons name head) ido-virtual-buffers))))
(setq ido-virtual-buffers
(cons (cons name (car head)) ido-virtual-buffers)))
(setq head (cdr head))))
(when ido-virtual-buffers (when ido-virtual-buffers
(if ido-use-faces (if ido-use-faces
(dolist (comp ido-virtual-buffers) (dolist (comp ido-virtual-buffers)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment