Function: savehist-mode
savehist-mode is an autoloaded, interactive and byte-compiled function
defined in savehist.el.gz.
Signature
(savehist-mode &optional ARG)
Documentation
Toggle saving of minibuffer history (Savehist mode).
This is a minor mode. If called interactively, toggle the Savehist
mode mode. If the prefix argument is positive, enable the mode, and
if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the
mode if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=savehist-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
When Savehist mode is enabled, minibuffer history is saved
to savehist-file periodically and when exiting Emacs. When
Savehist mode is enabled for the first time in an Emacs session,
it loads the previous minibuffer histories from savehist-file.
The variable savehist-autosave-interval controls the
periodicity of saving minibuffer histories.
If savehist-save-minibuffer-history is non-nil (the default),
all recorded minibuffer histories will be saved. You can arrange
for additional history variables to be saved and restored by
customizing savehist-additional-variables, which by default is
an empty list. For example, to save the history of commands
invoked via M-x (execute-extended-command), add command-history(var)/command-history(fun) to the list in
savehist-additional-variables.
Alternatively, you could customize savehist-save-minibuffer-history
to nil, and add to savehist-additional-variables only those
history variables you want to save.
To ignore some history variables, add their symbols to the list
in savehist-ignored-variables.
This mode should normally be turned on from your Emacs init file. Calling it at any other time replaces your current minibuffer histories, which is probably undesirable.
Probably introduced at or before Emacs version 22.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/savehist.el.gz
;; Functions.
;;;###autoload
(define-minor-mode savehist-mode
"Toggle saving of minibuffer history (Savehist mode).
When Savehist mode is enabled, minibuffer history is saved
to `savehist-file' periodically and when exiting Emacs. When
Savehist mode is enabled for the first time in an Emacs session,
it loads the previous minibuffer histories from `savehist-file'.
The variable `savehist-autosave-interval' controls the
periodicity of saving minibuffer histories.
If `savehist-save-minibuffer-history' is non-nil (the default),
all recorded minibuffer histories will be saved. You can arrange
for additional history variables to be saved and restored by
customizing `savehist-additional-variables', which by default is
an empty list. For example, to save the history of commands
invoked via \\[execute-extended-command], add `command-history' to the list in
`savehist-additional-variables'.
Alternatively, you could customize `savehist-save-minibuffer-history'
to nil, and add to `savehist-additional-variables' only those
history variables you want to save.
To ignore some history variables, add their symbols to the list
in `savehist-ignored-variables'.
This mode should normally be turned on from your Emacs init file.
Calling it at any other time replaces your current minibuffer
histories, which is probably undesirable."
:global t
(if (not savehist-mode)
(savehist-uninstall)
(when (and (not savehist-loaded)
(file-exists-p savehist-file))
(condition-case errvar
(progn
;; Don't set coding-system-for-read -- we rely on the
;; coding cookie to convey that information. That way, if
;; the user changes the value of savehist-coding-system,
;; we can still correctly load the old file.
(load savehist-file nil (not (called-interactively-p 'interactive)))
(setq savehist-loaded t))
(error
;; Don't install the mode if reading failed. Doing so would
;; effectively destroy the user's data at the next save.
(setq savehist-mode nil)
(savehist-uninstall)
(signal (car errvar) (cdr errvar)))))
(savehist-install)))