40 |
;; or with customize: `M-x customize-option RET savehist-mode RET'. |
;; or with customize: `M-x customize-option RET savehist-mode RET'. |
41 |
;; |
;; |
42 |
;; You can also explicitly save history with `M-x savehist-save' and |
;; You can also explicitly save history with `M-x savehist-save' and |
43 |
;; load it by loading the `savehist-file' with `M-x load'. |
;; load it by loading the `savehist-file' with `M-x load-file'. |
44 |
|
|
45 |
;; If you are using a version of Emacs that does not ship with this |
;; 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 |
;; package, be sure to have `savehist.el' in a directory that is in |
64 |
Set this by calling the `savehist-mode' function or using the customize |
Set this by calling the `savehist-mode' function or using the customize |
65 |
interface." |
interface." |
66 |
:type 'boolean |
:type 'boolean |
67 |
:set (lambda (symbol value) (savehist-mode (or value 0))) |
:set (if (fboundp 'custom-set-minor-mode) |
68 |
|
'custom-set-minor-mode |
69 |
|
(lambda (symbol value) (funcall symbol (or value 0)))) |
70 |
:initialize 'custom-initialize-default |
:initialize 'custom-initialize-default |
71 |
:require 'savehist |
:require 'savehist |
72 |
:group 'savehist) |
:group 'savehist) |
130 |
:group 'savehist) |
:group 'savehist) |
131 |
|
|
132 |
(defcustom savehist-save-hook nil |
(defcustom savehist-save-hook nil |
133 |
"Hook called by savehist-save before saving the variables. |
"Hook called by `savehist-save' before saving the variables. |
134 |
You can use this hook to influence choice and content of variables to |
You can use this hook to influence choice and content of variables to |
135 |
save." |
save." |
136 |
:type 'hook) |
:type 'hook) |
137 |
|
|
138 |
(defvar savehist-coding-system (if (featurep 'xemacs) 'iso-2022-8 'utf-8) |
(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) |
144 |
"The coding system savehist uses for saving the minibuffer history. |
"The coding system savehist uses for saving the minibuffer history. |
145 |
Changing this value while Emacs is running is supported, but considered |
Changing this value while Emacs is running is supported, but considered |
146 |
unwise, unless you know what you are doing.") |
unwise, unless you know what you are doing.") |
157 |
along with minibuffer history. You can change its value off |
along with minibuffer history. You can change its value off |
158 |
`savehist-save-hook' to influence which variables are saved.") |
`savehist-save-hook' to influence which variables are saved.") |
159 |
|
|
160 |
;; Coding system without any conversion, used for calculating an |
(defconst savehist-no-conversion (if (featurep 'xemacs) 'binary 'no-conversion) |
161 |
;; internal checksum. Should be as fast as possible, ideally simply |
"Coding system without conversion, used for calculating internal checksums. |
162 |
;; exposing the internal representation of buffer text. |
Should be as fast as possible, ideally simply exposing the internal |
163 |
(defconst savehist-no-conversion (if (featurep 'xemacs) 'binary 'no-conversion)) |
representation of buffer text.") |
164 |
|
|
165 |
;; Whether the history has already been loaded. This prevents |
(defvar savehist-loaded nil |
166 |
;; toggling savehist-mode from destroying existing minibuffer history. |
"Whether the history has already been loaded. |
167 |
(defvar savehist-loaded nil) |
This prevents toggling `savehist-mode' from destroying existing |
168 |
|
minibuffer history.") |
169 |
|
|
170 |
(eval-when-compile |
(eval-when-compile |
171 |
(when (featurep 'xemacs) |
(when (featurep 'xemacs) |
209 |
(setq savehist-mode nil) |
(setq savehist-mode nil) |
210 |
(savehist-uninstall) |
(savehist-uninstall) |
211 |
(signal (car errvar) (cdr errvar))))) |
(signal (car errvar) (cdr errvar))))) |
212 |
(savehist-install))) |
(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) |
224 |
(add-minor-mode 'savehist-mode "") |
(add-minor-mode 'savehist-mode "") |
225 |
|
|
226 |
(defun savehist-load () |
(defun savehist-load () |