From 8b461ecd3d4fae3be0a93523d19932e0a3d21c6c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 2 Jul 2026 22:37:06 -0400 Subject: fix: persist runtime favorite and saved locations in a state file savehist rewrites its whole file on every save, keeping only the variables registered in the running process. Any Emacs that saved savehist without wttrin loaded (a batch tool, a session that never opened wttrin) silently deleted the persisted favorite and saved-location entries. A d-set default then reverted to the init value on the next restart. The runtime favorite and directory now live in wttrin-state-file, written only by wttrin: write-through on every location command, atomic temp-file + rename, UTF-8 pinned both ways, read with read (never eval), versioned plist. Values restore at load and re-assert on savehist-mode-hook, so a stale legacy savehist restore can't clobber them. With no state file present, legacy savehist values are adopted and written once, so existing users migrate with zero steps. Search history stays on savehist. It's scrub-tolerant throwaway data, exactly what savehist is for. Also: the README documents the mode-line tooltip forecast option, and the gitignore covers one more local tooling artifact. --- tests/test-wttrin-make-default.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/test-wttrin-make-default.el') diff --git a/tests/test-wttrin-make-default.el b/tests/test-wttrin-make-default.el index e824194..c7954c8 100644 --- a/tests/test-wttrin-make-default.el +++ b/tests/test-wttrin-make-default.el @@ -60,13 +60,14 @@ unbound); persistence is left to `wttrin--savehist-register'." (wttrin--set-favorite-location "Berkeley, CA") (should (equal wttrin--location-history '("Oslo, NO"))))) -(ert-deftest test-wttrin-favorite-savehist-register-includes-favorite () - "Normal: `wttrin--savehist-register' registers the runtime override, not the -`wttrin-favorite-location' defcustom." +(ert-deftest test-wttrin-favorite-savehist-register-excludes-favorite () + "Normal: `wttrin--savehist-register' does not register the runtime override. +The favorite persists in `wttrin-state-file' instead — a savehist entry would +be scrubbed by any Emacs session that saves savehist without wttrin loaded." (require 'savehist) (let ((savehist-additional-variables '(kill-ring))) (wttrin--savehist-register) - (should (memq 'wttrin--favorite-override savehist-additional-variables)) + (should-not (memq 'wttrin--favorite-override savehist-additional-variables)) (should-not (memq 'wttrin-favorite-location savehist-additional-variables)))) ;;; -------------------------------------------------------------------------- -- cgit v1.2.3