Commit b6b5618c authored by David Ponce's avatar David Ponce
Browse files

(recentf-track-opened-file)

(recentf-track-closed-file, recentf-update-menu)
(recentf-used-hooks, recentf-enabled-p): Move before dialog stuff.
(recentf-dialog-mode-map): Map follow-link to RET, so dialogs obey
mouse-1-click-follows-link.
parent fc5c7550
2005-10-14 David Ponce <david@dponce.com>
* recentf.el (recentf-track-opened-file)
(recentf-track-closed-file, recentf-update-menu)
(recentf-used-hooks, recentf-enabled-p): Move before dialog stuff.
(recentf-dialog-mode-map): Map follow-link to RET, so dialogs obey
mouse-1-click-follows-link.
2005-10-13 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
* toolbar/diropen.xpm, toolbar/diropen.pbm: New versions made from
......
......@@ -985,6 +985,54 @@ unchanged."
t)))))
l))
;;; Hooks
;;
(defun recentf-track-opened-file ()
"Insert the name of the file just opened or written into the recent list."
(and buffer-file-name
(recentf-add-file buffer-file-name))
;; Must return nil because it is run from `write-file-functions'.
nil)
(defun recentf-track-closed-file ()
"Update the recent list when a buffer is killed.
That is, remove a non kept file from the recent list."
(and buffer-file-name
(recentf-remove-if-non-kept buffer-file-name)))
(defun recentf-update-menu ()
"Update the recentf menu from the current recent list."
(let ((cache (cons default-directory recentf-list)))
;; Does nothing, if nothing has changed.
(unless (equal recentf-data-cache cache)
(setq recentf-data-cache cache)
(condition-case err
(easy-menu-add-item
(recentf-menu-bar) recentf-menu-path
(easy-menu-create-menu recentf-menu-title
(recentf-make-menu-items))
recentf-menu-before)
(error
(message "recentf update menu failed: %s"
(error-message-string err)))))))
(defconst recentf-used-hooks
'(
(find-file-hook recentf-track-opened-file)
(write-file-functions recentf-track-opened-file)
(kill-buffer-hook recentf-track-closed-file)
(menu-bar-update-hook recentf-update-menu)
(kill-emacs-hook recentf-save-list)
)
"Hooks used by recentf.")
(defsubst recentf-enabled-p ()
"Return non-nil if recentf mode is currently enabled."
(memq 'recentf-update-menu menu-bar-update-hook))
;;; Commands
;;
;;; Common dialog stuff
;;
(defun recentf-cancel-dialog (&rest ignore)
......@@ -1011,7 +1059,7 @@ Go to the beginning of buffer if not found."
(let ((km (copy-keymap recentf--shortcuts-keymap)))
(set-keymap-parent km widget-keymap)
(define-key km "q" 'recentf-cancel-dialog)
(define-key km [down-mouse-1] 'widget-button-click)
(define-key km [follow-link] "\C-m")
km)
"Keymap used in recentf dialogs.")
......@@ -1038,54 +1086,6 @@ Go to the beginning of buffer if not found."
(widget-setup)
(switch-to-buffer (current-buffer))))
;;; Hooks
;;
(defun recentf-track-opened-file ()
"Insert the name of the file just opened or written into the recent list."
(and buffer-file-name
(recentf-add-file buffer-file-name))
;; Must return nil because it is run from `write-file-functions'.
nil)
(defun recentf-track-closed-file ()
"Update the recent list when a buffer is killed.
That is, remove a non kept file from the recent list."
(and buffer-file-name
(recentf-remove-if-non-kept buffer-file-name)))
(defun recentf-update-menu ()
"Update the recentf menu from the current recent list."
(let ((cache (cons default-directory recentf-list)))
;; Does nothing, if nothing has changed.
(unless (equal recentf-data-cache cache)
(setq recentf-data-cache cache)
(condition-case err
(easy-menu-add-item
(recentf-menu-bar) recentf-menu-path
(easy-menu-create-menu recentf-menu-title
(recentf-make-menu-items))
recentf-menu-before)
(error
(message "recentf update menu failed: %s"
(error-message-string err)))))))
(defconst recentf-used-hooks
'(
(find-file-hook recentf-track-opened-file)
(write-file-functions recentf-track-opened-file)
(kill-buffer-hook recentf-track-closed-file)
(menu-bar-update-hook recentf-update-menu)
(kill-emacs-hook recentf-save-list)
)
"Hooks used by recentf.")
(defsubst recentf-enabled-p ()
"Return non-nil if recentf mode is currently enabled."
(memq 'recentf-update-menu menu-bar-update-hook))
;;; Commands
;;
;;; Edit list dialog
;;
(defvar recentf-edit-list nil)
......@@ -1140,7 +1140,7 @@ Click on Cancel or type `q' to cancel.\n")
:notify 'recentf-cancel-dialog
"Cancel")
(recentf-dialog-goto-first 'checkbox)))
;;; Open file dialog
;;
(defun recentf-open-files-action (widget &rest ignore)
......@@ -1252,7 +1252,7 @@ Optional argument N must be a valid digit number. It defaults to 1.
(when recentf--files-with-key
(kill-buffer (current-buffer)))
(funcall recentf-menu-action file)))
;;; Save/load/cleanup the recent list
;;
(defconst recentf-save-file-header
......@@ -1316,7 +1316,9 @@ That is, remove duplicates, non-kept, and excluded files."
(message "File %s removed from the recentf list" f)))
(message "Cleaning up the recentf list...done (%d removed)" n)
(setq recentf-list (nreverse newlist))))
;;; The minor mode
;;
(defvar recentf-mode-map (make-sparse-keymap)
"Keymap to use in recentf mode.")
......
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