(defcustom recentf-menu-path '("files")
"*Path where to add the recentf menu.
-If nil add it at top-level (see also `easy-menu-change')."
+If nil add it at top level (see also `easy-menu-change')."
:group 'recentf
:type '(choice (const :tag "Top Level" nil)
(sexp :tag "Menu Path"))
(add-hook 'kill-buffer-hook 'recentf-remove-file-hook))
(custom-set-default sym val)))
-(defcustom recentf-mode nil
- "Toggle recentf mode.
-When recentf mode is enabled, it maintains a menu for visiting files that
-were operated on recently.
-Setting this variable directly does not take effect;
-use either \\[customize] or the function `recentf-mode'."
- :set (lambda (symbol value)
- (recentf-mode (or value 0)))
- :initialize 'custom-initialize-default
- :type 'boolean
- :group 'recentf
- :require 'recentf)
-
(defcustom recentf-load-hook nil
"*Normal hook run at end of loading the `recentf' package."
:group 'recentf
:type 'hook)
-;;;
-;;; Common functions
-;;;
+;;;;
+;;;; Common functions
+;;;;
(defconst recentf-case-fold-search
(memq system-type '(vax-vms windows-nt))
"Non-nil if recentf searches and matches should ignore case.")
(defun recentf-include-p (filename)
- "Return t if FILENAME matches none of the `recentf-exclude' regexps."
+ "Return t if FILENAME match none of the `recentf-exclude' regexps."
(let ((case-fold-search recentf-case-fold-search)
(rl recentf-exclude))
(while (and rl (not (string-match (car rl) filename)))
(defun recentf-apply-menu-filter (filter l)
"Apply function FILTER to the list of menu-elements L.
It takes care of sub-menu elements in L and recursively apply FILTER
-to them. It is guarantee than FILTER receives only a list of single
+to them. It is guaranteed that FILTER receives only a list of single
menu-elements (no sub-menu)."
(if (and (functionp filter) l)
(let ((case-fold-search recentf-case-fold-search)
recentf-menu-items-for-commands)))))
(defun recentf-make-menu-item (menu-element)
- "Make a menu item from a menu element (see `recentf-make-menu-element')."
+ "Make a menu item from MENU-ELEMENT (see `recentf-make-menu-element')."
(let ((menu-item (recentf-menu-element-item menu-element))
(menu-value (recentf-menu-element-value menu-element)))
(if (recentf-sub-menu-element-p menu-element)
(list recentf-menu-action menu-value)
t))))
-;;;
-;;; Predefined menu filter functions
-;;;
+;;;;
+;;;; Predefined menu filter functions
+;;;;
(defun recentf-sort-ascending (l)
"Sort the list of menu elements L in ascending order.
t)))))
l))
-;;;
-;;; Dialogs stuff
-;;;
+;;;;
+;;;; Dialogs stuff
+;;;;
(defun recentf-cancel-dialog (&rest ignore)
"Cancel the current dialog.
(defun recentf-dialog-mode ()
"Major mode used in recentf dialogs.
-These are the special commands of recentf-dialog-mode mode:
+These are the special commands of `recentf-dialog-mode' mode:
q -- cancel this dialog."
(interactive)
(setq major-mode 'recentf-dialog-mode)
(setq mode-name "recentf-dialog")
(use-local-map recentf-dialog-mode-map))
-;;;
-;;; Hooks and Commands
-;;;
+;;;;
+;;;; Hooks and Commands
+;;;;
(defun recentf-add-file-hook ()
"Insert the name of the file just opened or written into `recentf-list'."
Holds list of files to be deleted from `recentf-list'.")
(defun recentf-edit-list-action (widget &rest ignore)
- "Checkbox widget action used by `recentf-edit-list' to select/unselect a file."
+ "Checkbox WIDGET action used by `recentf-edit-list' to select/unselect a file."
(let ((value (widget-get widget ':tag)))
;; if value is already in the selected items
(if (memq value recentf-edit-selected-items)
(setq recentf-update-menu-p t))
(defun recentf-open-files-action (widget &rest ignore)
- "Button widget action used by `recentf-open-files' to open a file."
+ "Button WIDGET action used by `recentf-open-files' to open a file."
(kill-buffer (current-buffer))
(funcall recentf-menu-action (widget-value widget)))
"String used by `recentf-open-files' to shift right sub-menu items.")
(defun recentf-open-files-item (menu-element)
- "Insert menu-element item in the current interaction buffer."
+ "Insert MENU-ELEMENT item in the current interaction buffer."
(let ((menu-item (car menu-element))
(file-path (cdr menu-element)))
(if (consp file-path) ; This is a sub-menu
(defun recentf-open-files (&optional files buffer-name)
"Display buffer allowing user to choose a file from recently-opened list.
The optional argument FILES may be used to specify the list, otherwise
-recentf-list is used. The optional argument BUFFER-NAME specifies
+`recentf-list' is used. The optional argument BUFFER-NAME specifies
which buffer to use for the interaction."
(interactive)
(if (null files)
(recentf-open-files (nthcdr recentf-max-menu-items recentf-list)
(concat "*" recentf-menu-title " - More*")))
+
+;;; Note this definition must be at the end of the file, because
+;;; `define-minor-mode' actually calls the mode-function if the
+;;; associated variable is non-nil, which requires that all needed
+;;; functions be already defined. [This is arguably a bug in d-m-m]
;;;###autoload
-(defun recentf-mode (&optional arg)
+(define-minor-mode recentf-mode
"Toggle recentf mode.
-With prefix ARG, turn recentf mode on if and only if ARG is positive.
-Returns the new status of recentf mode (non-nil means on).
+With prefix argument ARG, turn on if positive, otherwise off.
+Returns non-nil if the new state is enabled.
When recentf mode is enabled, it maintains a menu for visiting files that
were operated on recently."
- (interactive "P")
- (let ((on-p (if arg
- (> (prefix-numeric-value arg) 0)
- (not recentf-mode))))
- (if on-p
- (unless recentf-initialized-p
- (setq recentf-initialized-p t)
- (if (file-readable-p recentf-save-file)
- (load-file recentf-save-file))
- (setq recentf-update-menu-p t)
- (add-hook 'find-file-hooks 'recentf-add-file-hook)
- (add-hook 'write-file-hooks 'recentf-add-file-hook)
- (add-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
- (add-hook 'kill-emacs-hook 'recentf-save-list))
- (when recentf-initialized-p
- (setq recentf-initialized-p nil)
- (recentf-save-list)
- (easy-menu-remove-item nil recentf-menu-path recentf-menu-title)
- (remove-hook 'find-file-hooks 'recentf-add-file-hook)
- (remove-hook 'write-file-hooks 'recentf-add-file-hook)
- (remove-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
- (remove-hook 'kill-emacs-hook 'recentf-save-list)))
- (setq recentf-mode on-p)))
+ nil nil nil
+ :global t
+ :group 'recentf
+ (if recentf-mode
+ (unless recentf-initialized-p
+ (setq recentf-initialized-p t)
+ (if (file-readable-p recentf-save-file)
+ (load-file recentf-save-file))
+ (setq recentf-update-menu-p t)
+ (add-hook 'find-file-hooks 'recentf-add-file-hook)
+ (add-hook 'write-file-hooks 'recentf-add-file-hook)
+ (add-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
+ (add-hook 'kill-emacs-hook 'recentf-save-list))
+ (when recentf-initialized-p
+ (setq recentf-initialized-p nil)
+ (recentf-save-list)
+ (easy-menu-remove-item nil recentf-menu-path recentf-menu-title)
+ (remove-hook 'find-file-hooks 'recentf-add-file-hook)
+ (remove-hook 'write-file-hooks 'recentf-add-file-hook)
+ (remove-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
+ (remove-hook 'kill-emacs-hook 'recentf-save-list))))
+
(provide 'recentf)
(run-hooks 'recentf-load-hook)
-;;; recentf.el ends here.
+;;; recentf.el ends here