aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin-location-history.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-24 00:10:51 -0400
committerCraig Jennings <c@cjennings.net>2026-06-24 00:10:51 -0400
commitefd3cdce5b3aebfdb3e02460d1ec0434cef85949 (patch)
treeae8746cc7699b7e989d253f4c816fc7798a8e040 /tests/test-wttrin-location-history.el
parent4d46eafaa087f5570ece9d2e5f5d2ba6bc0d824e (diff)
downloademacs-wttrin-efd3cdce5b3aebfdb3e02460d1ec0434cef85949.tar.gz
emacs-wttrin-efd3cdce5b3aebfdb3e02460d1ec0434cef85949.zip
feat: add 'd' key to make the displayed location the default
I bound d in the weather buffer to wttrin-make-default, which sets wttrin-favorite-location to the location on screen so it drives the mode-line and future sessions. The footer advertises "[d] to make default". Persistence rides savehist, not the Emacs custom-variable mechanism: wttrin--savehist-register registers wttrin-favorite-location alongside the search history, at load and on savehist-save-hook. Enable savehist-mode and the favorite survives restarts. Promoting a location drops it from the search history, the way wttrin-default-locations entries are kept out of history. The favorite shows in the picker instead: wttrin--completion-candidates prepends it when it's a string and not already a default, so it appears exactly once. The setter only assigns the variable and trims history. It doesn't register with savehist itself, because savehist-additional-variables is unbound until savehist loads, so a direct add-to-list would error for users without savehist. Registration stays on the load and save-hook path.
Diffstat (limited to 'tests/test-wttrin-location-history.el')
-rw-r--r--tests/test-wttrin-location-history.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/test-wttrin-location-history.el b/tests/test-wttrin-location-history.el
index d23bdcd..61b495c 100644
--- a/tests/test-wttrin-location-history.el
+++ b/tests/test-wttrin-location-history.el
@@ -211,11 +211,13 @@
(should (memq 'wttrin--location-history savehist-additional-variables))))
(ert-deftest test-wttrin-location-history-boundary-savehist-register-idempotent ()
- "Registering when already present does not duplicate the entry."
+ "Registering an already-present variable does not duplicate it."
(require 'savehist)
- (let ((savehist-additional-variables '(wttrin--location-history)))
+ (require 'cl-lib)
+ (let ((savehist-additional-variables '(wttrin--location-history wttrin-favorite-location)))
(wttrin--savehist-register)
- (should (equal '(wttrin--location-history) savehist-additional-variables))))
+ (should (= 1 (cl-count 'wttrin--location-history savehist-additional-variables)))
+ (should (= 1 (cl-count 'wttrin-favorite-location savehist-additional-variables)))))
(ert-deftest test-wttrin-location-history-integration-savehist-register-on-save-hook ()
"The registration runs on `savehist-save-hook' so it survives a clobber."