From eaabae3b01b8bdc05a5892492c06a8131c195a45 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 21 Jun 2026 09:11:38 -0400 Subject: fix: keep location history registered after a savehist setq A one-time add-to-list put wttrin--location-history into savehist-additional-variables when savehist loaded. Any user who later setqs that list, a common config pattern for curating which histories persist, replaces it and drops the entry. The search history then silently never saves. Re-assert the registration on savehist-save-hook, which runs at the top of every savehist-save. The variable is now in the list whenever a save happens, regardless of init order or a clobbering setq. Restore was never affected, since savehist reloads the value from explicit setq forms in its file. The README persistence note now reflects this: the variable stays registered even if you set savehist-additional-variables yourself. --- wttrin.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'wttrin.el') diff --git a/wttrin.el b/wttrin.el index f9d10f0..150e934 100644 --- a/wttrin.el +++ b/wttrin.el @@ -509,9 +509,17 @@ Persisted across sessions via `savehist-mode'.") ;; Declared so the byte-compiler doesn't warn; savehist defines it for real. (defvar savehist-additional-variables) -(with-eval-after-load 'savehist +(defun wttrin--savehist-register () + "Ensure `wttrin--location-history' is persisted by savehist. +Run both at load and on `savehist-save-hook', so the registration survives a +user `setq' of `savehist-additional-variables' (a common config pattern) that +would otherwise drop the entry before it could be saved." (add-to-list 'savehist-additional-variables 'wttrin--location-history)) +(with-eval-after-load 'savehist + (wttrin--savehist-register) + (add-hook 'savehist-save-hook #'wttrin--savehist-register)) + (defun wttrin--add-to-location-history (location) "Record LOCATION as a recent successful search. No-op when LOCATION is nil, empty, or already a default location. An existing -- cgit v1.2.3