aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-11-01 06:09:32 +0000
committerStefan Monnier2005-11-01 06:09:32 +0000
commitb13e8fb33608f0aeae4747aa40411facecad2bac (patch)
tree05576e6ec22ad485f346d14ce7e82064a4dd11bb
parentb91f17dcc62ba3e510bb26f2a9dd6124269686c1 (diff)
downloademacs-b13e8fb33608f0aeae4747aa40411facecad2bac.tar.gz
emacs-b13e8fb33608f0aeae4747aa40411facecad2bac.zip
(savehist-mode) <defcustom>: Use custom-set-minor-mode if available.
(savehist-mode) <defun>: Run the minor mode hook, set the custom state and emit a message if applicable.
-rw-r--r--lisp/savehist.el43
1 files changed, 31 insertions, 12 deletions
diff --git a/lisp/savehist.el b/lisp/savehist.el
index a6e445435a2..6c85fb7c635 100644
--- a/lisp/savehist.el
+++ b/lisp/savehist.el
@@ -40,7 +40,7 @@
40;; or with customize: `M-x customize-option RET savehist-mode RET'. 40;; or with customize: `M-x customize-option RET savehist-mode RET'.
41;; 41;;
42;; You can also explicitly save history with `M-x savehist-save' and 42;; You can also explicitly save history with `M-x savehist-save' and
43;; load it by loading the `savehist-file' with `M-x load'. 43;; load it by loading the `savehist-file' with `M-x load-file'.
44 44
45;; If you are using a version of Emacs that does not ship with this 45;; If you are using a version of Emacs that does not ship with this
46;; package, be sure to have `savehist.el' in a directory that is in 46;; package, be sure to have `savehist.el' in a directory that is in
@@ -64,7 +64,9 @@
64Set this by calling the `savehist-mode' function or using the customize 64Set this by calling the `savehist-mode' function or using the customize
65interface." 65interface."
66 :type 'boolean 66 :type 'boolean
67 :set (lambda (symbol value) (savehist-mode (or value 0))) 67 :set (if (fboundp 'custom-set-minor-mode)
68 'custom-set-minor-mode
69 (lambda (symbol value) (funcall symbol (or value 0))))
68 :initialize 'custom-initialize-default 70 :initialize 'custom-initialize-default
69 :require 'savehist 71 :require 'savehist
70 :group 'savehist) 72 :group 'savehist)
@@ -128,12 +130,17 @@ If set to nil, disables timer-based autosaving."
128 :group 'savehist) 130 :group 'savehist)
129 131
130(defcustom savehist-save-hook nil 132(defcustom savehist-save-hook nil
131 "Hook called by savehist-save before saving the variables. 133 "Hook called by `savehist-save' before saving the variables.
132You can use this hook to influence choice and content of variables to 134You can use this hook to influence choice and content of variables to
133save." 135save."
134 :type 'hook) 136 :type 'hook)
135 137
136(defvar savehist-coding-system (if (featurep 'xemacs) 'iso-2022-8 'utf-8) 138(defvar savehist-coding-system
139 ;; UTF-8 is usually preferable to ISO-2022-8 when available, but under
140 ;; XEmacs, UTF-8 is provided by external packages, and may not always be
141 ;; available, so even if it currently is available, we prefer not to
142 ;; use is.
143 (if (featurep 'xemacs) 'iso-2022-8 'utf-8)
137 "The coding system savehist uses for saving the minibuffer history. 144 "The coding system savehist uses for saving the minibuffer history.
138Changing this value while Emacs is running is supported, but considered 145Changing this value while Emacs is running is supported, but considered
139unwise, unless you know what you are doing.") 146unwise, unless you know what you are doing.")
@@ -150,14 +157,15 @@ The contents of this variable is built while Emacs is running, and saved
150along with minibuffer history. You can change its value off 157along with minibuffer history. You can change its value off
151`savehist-save-hook' to influence which variables are saved.") 158`savehist-save-hook' to influence which variables are saved.")
152 159
153;; Coding system without any conversion, used for calculating an 160(defconst savehist-no-conversion (if (featurep 'xemacs) 'binary 'no-conversion)
154;; internal checksum. Should be as fast as possible, ideally simply 161 "Coding system without conversion, used for calculating internal checksums.
155;; exposing the internal representation of buffer text. 162Should be as fast as possible, ideally simply exposing the internal
156(defconst savehist-no-conversion (if (featurep 'xemacs) 'binary 'no-conversion)) 163representation of buffer text.")
157 164
158;; Whether the history has already been loaded. This prevents 165(defvar savehist-loaded nil
159;; toggling savehist-mode from destroying existing minibuffer history. 166 "Whether the history has already been loaded.
160(defvar savehist-loaded nil) 167This prevents toggling `savehist-mode' from destroying existing
168minibuffer history.")
161 169
162(eval-when-compile 170(eval-when-compile
163 (when (featurep 'xemacs) 171 (when (featurep 'xemacs)
@@ -201,7 +209,18 @@ which is probably undesirable."
201 (setq savehist-mode nil) 209 (setq savehist-mode nil)
202 (savehist-uninstall) 210 (savehist-uninstall)
203 (signal (car errvar) (cdr errvar))))) 211 (signal (car errvar) (cdr errvar)))))
204 (savehist-install))) 212 (savehist-install))
213
214 ;; End with the usual minor-mode conventions normally provided
215 ;; transparently by define-minor-mode.
216 (run-hooks 'savehist-mode-hook)
217 (if (interactive-p)
218 (progn
219 (customize-mark-as-set 'savehist-mode)
220 (unless (current-message)
221 (message "Savehist mode %sabled" (if savehist-mode "en" "dis")))))
222 ;; Return the new setting.
223 savehist-mode)
205(add-minor-mode 'savehist-mode "") 224(add-minor-mode 'savehist-mode "")
206 225
207(defun savehist-load () 226(defun savehist-load ()