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-favorite-override.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/test-wttrin-favorite-override.el') diff --git a/tests/test-wttrin-favorite-override.el b/tests/test-wttrin-favorite-override.el index 0236901..95916c7 100644 --- a/tests/test-wttrin-favorite-override.el +++ b/tests/test-wttrin-favorite-override.el @@ -64,15 +64,18 @@ with `d' reverted to the init value on restart." (should (equal "New Orleans, LA" wttrin-favorite-location)) (should (equal "Paris, FR" (wttrin--favorite-location))))) -;;; savehist registration targets the runtime vars, not the config defcustoms +;;; savehist registration covers only the scrub-tolerant search history; +;;; the runtime vars persist in `wttrin-state-file' (see test-wttrin-state-file.el) -(ert-deftest test-wttrin-favorite-override-normal-savehist-registers-override () - "Normal: savehist persists the override, not the config defcustom." +(ert-deftest test-wttrin-favorite-override-normal-savehist-excludes-runtime-vars () + "Normal: savehist persists neither the runtime vars nor the config defcustoms. +The runtime favorite and directory live in `wttrin-state-file' — a savehist +entry would be scrubbed by any session that saves savehist without wttrin." (require 'savehist) (let ((savehist-additional-variables '(kill-ring))) (wttrin--savehist-register) - (should (memq 'wttrin--favorite-override savehist-additional-variables)) - (should (memq 'wttrin--saved-locations-runtime savehist-additional-variables)) + (should-not (memq 'wttrin--favorite-override savehist-additional-variables)) + (should-not (memq 'wttrin--saved-locations-runtime savehist-additional-variables)) (should-not (memq 'wttrin-favorite-location savehist-additional-variables)) (should-not (memq 'wttrin-saved-locations savehist-additional-variables)))) -- cgit v1.2.3