aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin--add-buffer-instructions.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--add-buffer-instructions.el
parent4d46eafaa087f5570ece9d2e5f5d2ba6bc0d824e (diff)
downloademacs-wttrin-efd3cdce5b3aebfdb3e02460d1ec0434cef85949.tar.gz
emacs-wttrin-efd3cdce5b3aebfdb3e02460d1ec0434cef85949.zip
feat: add 'd' key to make the displayed location the defaultHEADmain
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--add-buffer-instructions.el')
-rw-r--r--tests/test-wttrin--add-buffer-instructions.el12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/test-wttrin--add-buffer-instructions.el b/tests/test-wttrin--add-buffer-instructions.el
index 0f1c382..425832d 100644
--- a/tests/test-wttrin--add-buffer-instructions.el
+++ b/tests/test-wttrin--add-buffer-instructions.el
@@ -28,7 +28,7 @@
"Test adding instructions to empty buffer."
(with-temp-buffer
(wttrin--add-buffer-instructions)
- (should (string= "\n\nPress: [a] for another location [g] to refresh [q] to quit"
+ (should (string= "\n\nPress: [a] for another location [g] to refresh [d] to make default [q] to quit"
(buffer-string)))))
(ert-deftest test-wttrin--add-buffer-instructions-normal-with-existing-content-appends-instructions ()
@@ -36,7 +36,7 @@
(with-temp-buffer
(insert "Weather: Sunny\nTemperature: 20°C")
(wttrin--add-buffer-instructions)
- (should (string= "Weather: Sunny\nTemperature: 20°C\n\nPress: [a] for another location [g] to refresh [q] to quit"
+ (should (string= "Weather: Sunny\nTemperature: 20°C\n\nPress: [a] for another location [g] to refresh [d] to make default [q] to quit"
(buffer-string)))))
(ert-deftest test-wttrin--add-buffer-instructions-normal-preserves-point-moves-to-end ()
@@ -99,7 +99,7 @@
(insert "Weather data here")
(goto-char (point-min))
(wttrin--add-buffer-instructions)
- (should (string-suffix-p "Press: [a] for another location [g] to refresh [q] to quit"
+ (should (string-suffix-p "Press: [a] for another location [g] to refresh [d] to make default [q] to quit"
(buffer-string)))))
(ert-deftest test-wttrin--add-buffer-instructions-boundary-point-in-middle-appends-at-end ()
@@ -109,7 +109,7 @@
(goto-char (point-min))
(forward-line 1)
(wttrin--add-buffer-instructions)
- (should (string-suffix-p "Press: [a] for another location [g] to refresh [q] to quit"
+ (should (string-suffix-p "Press: [a] for another location [g] to refresh [d] to make default [q] to quit"
(buffer-string)))))
(ert-deftest test-wttrin--add-buffer-instructions-boundary-trailing-newlines-preserves-newlines ()
@@ -117,7 +117,7 @@
(with-temp-buffer
(insert "Weather\n\n\n")
(wttrin--add-buffer-instructions)
- (should (string= "Weather\n\n\n\n\nPress: [a] for another location [g] to refresh [q] to quit"
+ (should (string= "Weather\n\n\n\n\nPress: [a] for another location [g] to refresh [d] to make default [q] to quit"
(buffer-string)))))
(ert-deftest test-wttrin--add-buffer-instructions-boundary-very-large-buffer-appends-at-end ()
@@ -126,7 +126,7 @@
(insert (make-string 10000 ?x))
(wttrin--add-buffer-instructions)
(goto-char (point-max))
- (should (looking-back "Press: \\[a\\] for another location \\[g\\] to refresh \\[q\\] to quit" nil))))
+ (should (looking-back "Press: \\[a\\] for another location \\[g\\] to refresh \\[d\\] to make default \\[q\\] to quit" nil))))
;;; Error Cases