Home > Net >  changing the value of savehist-minibuffer-history-variables in Emacs
changing the value of savehist-minibuffer-history-variables in Emacs

Time:10-29

It says on lines 129-130 of https://github.com/emacs-mirror/emacs/blob/master/lisp/savehist.el that the default behaviour is to determine the contents of savehist-minibuffer-history-variables while emacs is running. I indeed see in my savehist-file that this appears to be yes-or-no-p-history, buffer-name-history and a few other variables.

However, I would like to save only a specific history in emacs, namely that of filesets-data, implemented via

(setq savehist-additional-variables '(filesets-data))

It says on lines 59-60 of savehist.el that this can be achieved by using savehist-save-hook to change the value of savehist-minibuffer-history-variables.

I unfortunately cannot figure out how to do that. I have tried

(setq savehist-minibuffer-history-variables nil)
(add-hook 'savehist-save-hook 'savehist-minibuffer-history-variables)

in my .emacs.d but that yields an error message:

Symbol’s function definition is void: savehist-minibuffer-history-variables

Any help on changing savehist-minibuffer-history-variables to be empty when exiting emacs is appreciated. Thanks!

CodePudding user response:

The thing you put on a hook is a function, not a variable (and not some other sexp).

(defun foo ()
  (setq savehist-minibuffer-history-variables nil))

(add-hook 'savehist-save-hook #'foo)
  • Related