aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2000-10-25 11:38:08 +0000
committerMiles Bader2000-10-25 11:38:08 +0000
commita30ccae670fd30dcffca14a9bd499cccc8dae044 (patch)
treed20eae7816ffd8266b5e5adea796d7120dfbedb8
parente90813b8f68416728fe74454c52ec0d83b8516d0 (diff)
downloademacs-a30ccae670fd30dcffca14a9bd499cccc8dae044.tar.gz
emacs-a30ccae670fd30dcffca14a9bd499cccc8dae044.zip
(recentf-mode): Variable removed.
(recentf-mode): Use `define-minor-mode'.
-rw-r--r--lisp/recentf.el69
1 files changed, 30 insertions, 39 deletions
diff --git a/lisp/recentf.el b/lisp/recentf.el
index 2f357651dee..a107454f416 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -177,19 +177,6 @@ used to build the menu and must return a new list of menu elements (see
177 (add-hook 'kill-buffer-hook 'recentf-remove-file-hook)) 177 (add-hook 'kill-buffer-hook 'recentf-remove-file-hook))
178 (custom-set-default sym val))) 178 (custom-set-default sym val)))
179 179
180(defcustom recentf-mode nil
181 "Toggle recentf mode.
182When recentf mode is enabled, it maintains a menu for visiting files that
183were operated on recently.
184Setting this variable directly does not take effect;
185use either \\[customize] or the function `recentf-mode'."
186 :set (lambda (symbol value)
187 (recentf-mode (or value 0)))
188 :initialize 'custom-initialize-default
189 :type 'boolean
190 :group 'recentf
191 :require 'recentf)
192
193(defcustom recentf-load-hook nil 180(defcustom recentf-load-hook nil
194 "*Normal hook run at end of loading the `recentf' package." 181 "*Normal hook run at end of loading the `recentf' package."
195 :group 'recentf 182 :group 'recentf
@@ -1021,37 +1008,41 @@ which buffer to use for the interaction."
1021 (recentf-open-files (nthcdr recentf-max-menu-items recentf-list) 1008 (recentf-open-files (nthcdr recentf-max-menu-items recentf-list)
1022 (concat "*" recentf-menu-title " - More*"))) 1009 (concat "*" recentf-menu-title " - More*")))
1023 1010
1011
1012;;; Note this definition must be at the end of the file, because
1013;;; `define-minor-mode' actually calls the mode-function if the
1014;;; associated variable is non-nil, which requires that all needed
1015;;; functions be already defined. [This is arguably a bug in d-m-m]
1024;;;###autoload 1016;;;###autoload
1025(defun recentf-mode (&optional arg) 1017(define-minor-mode recentf-mode
1026 "Toggle recentf mode. 1018 "Toggle recentf mode.
1027With prefix ARG, turn recentf mode on if and only if ARG is positive. 1019With prefix argument ARG, turn on if positive, otherwise off.
1028Returns the new status of recentf mode (non-nil means on). 1020Returns non-nil if the new state is enabled.
1029 1021
1030When recentf mode is enabled, it maintains a menu for visiting files that 1022When recentf mode is enabled, it maintains a menu for visiting files that
1031were operated on recently." 1023were operated on recently."
1032 (interactive "P") 1024 nil nil nil
1033 (let ((on-p (if arg 1025 :global t
1034 (> (prefix-numeric-value arg) 0) 1026 :group 'recentf
1035 (not recentf-mode)))) 1027 (if recentf-mode
1036 (if on-p 1028 (unless recentf-initialized-p
1037 (unless recentf-initialized-p 1029 (setq recentf-initialized-p t)
1038 (setq recentf-initialized-p t) 1030 (if (file-readable-p recentf-save-file)
1039 (if (file-readable-p recentf-save-file) 1031 (load-file recentf-save-file))
1040 (load-file recentf-save-file)) 1032 (setq recentf-update-menu-p t)
1041 (setq recentf-update-menu-p t) 1033 (add-hook 'find-file-hooks 'recentf-add-file-hook)
1042 (add-hook 'find-file-hooks 'recentf-add-file-hook) 1034 (add-hook 'write-file-hooks 'recentf-add-file-hook)
1043 (add-hook 'write-file-hooks 'recentf-add-file-hook) 1035 (add-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
1044 (add-hook 'menu-bar-update-hook 'recentf-update-menu-hook) 1036 (add-hook 'kill-emacs-hook 'recentf-save-list))
1045 (add-hook 'kill-emacs-hook 'recentf-save-list)) 1037 (when recentf-initialized-p
1046 (when recentf-initialized-p 1038 (setq recentf-initialized-p nil)
1047 (setq recentf-initialized-p nil) 1039 (recentf-save-list)
1048 (recentf-save-list) 1040 (easy-menu-remove-item nil recentf-menu-path recentf-menu-title)
1049 (easy-menu-remove-item nil recentf-menu-path recentf-menu-title) 1041 (remove-hook 'find-file-hooks 'recentf-add-file-hook)
1050 (remove-hook 'find-file-hooks 'recentf-add-file-hook) 1042 (remove-hook 'write-file-hooks 'recentf-add-file-hook)
1051 (remove-hook 'write-file-hooks 'recentf-add-file-hook) 1043 (remove-hook 'menu-bar-update-hook 'recentf-update-menu-hook)
1052 (remove-hook 'menu-bar-update-hook 'recentf-update-menu-hook) 1044 (remove-hook 'kill-emacs-hook 'recentf-save-list))))
1053 (remove-hook 'kill-emacs-hook 'recentf-save-list))) 1045
1054 (setq recentf-mode on-p)))
1055 1046
1056(provide 'recentf) 1047(provide 'recentf)
1057 1048