From 2f2fbae88280a460d2750ee685351475145e9d55 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 20 Apr 2025 10:10:17 -0400 Subject: [PATCH] (savehist-minibuffer-hook): Exclude uninterned history vars * lisp/savehist.el (savehist--reload): Don't bother merging the value of vars that were not changed. (savehist-minibuffer-hook): Exclude uninterned history vars. --- lisp/savehist.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/savehist.el b/lisp/savehist.el index 34226b3bd81..2cd591bc04f 100644 --- a/lisp/savehist.el +++ b/lisp/savehist.el @@ -243,7 +243,8 @@ Be careful to do it while preserving the current history data." ;; For each histvar that we knew about, make sure all the entries that ;; were there before are still here now and in the same order. (with-demoted-errors "%S" ;Maybe some var is not a list or something. - (set s (savehist--merge v (symbol-value s)))))))) + (unless (equal v (symbol-value s)) + (set s (savehist--merge v (symbol-value s))))))))) (defun savehist--file-modtime () (or (file-attribute-modification-time (file-attributes savehist-file)) @@ -443,7 +444,12 @@ Does nothing if Savehist mode is off." ;; (which `read-password' does), ;; `minibuffer-history-variable' is bound to t to mean ;; "no history is being recorded". - (memq minibuffer-history-variable savehist-ignored-variables)) + (memq minibuffer-history-variable savehist-ignored-variables) + ;; Filter out uninterned history vars since we can't + ;; reliably write+read them back in anyway (and presumably + ;; they are not intended to survive sessions). + (not (eq (intern-soft minibuffer-history-variable) + minibuffer-history-variable))) (add-to-list 'savehist-minibuffer-history-variables minibuffer-history-variable)))