aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin-location-history.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-25 12:15:34 -0400
committerCraig Jennings <c@cjennings.net>2026-06-25 12:15:34 -0400
commit33621b5a6e5407da190767b89756e287698ef234 (patch)
tree5ff74e05a81a4ace888a18245304cc28c51dfc3c /tests/test-wttrin-location-history.el
parent4266923daf6f137fbe2897334b7669f7fb4633c8 (diff)
downloademacs-wttrin-33621b5a6e5407da190767b89756e287698ef234.tar.gz
emacs-wttrin-33621b5a6e5407da190767b89756e287698ef234.zip
feat: add current-location detection to the weather picker
Geolocation used to live in a separate command, so getting weather for where you are meant knowing a second command existed. I added a "Current location (detect)" entry pinned to the top of the M-x wttrin picker. Selecting it detects your location and shows its weather. If the guess is wrong (VPN, hotspot) the detected city is visible in the header, so you reopen the picker and type one. Press d to keep the detected city as the default. The entry is pinned first through a completion table whose display-sort-function holds against completion frameworks that re-sort, and it never enters location history or the cache as a place. A new wttrin-geolocation-enabled (default t) turns every geolocation surface off for users who want that: the picker entry, the auto-detect favorite, and the command. It stays on by default. The older wttrin-set-location-from-geolocation command is now obsolete in favor of the picker. Its customize-save-variable persistence advice is replaced by savehist, which already carries the favorite across sessions.
Diffstat (limited to 'tests/test-wttrin-location-history.el')
-rw-r--r--tests/test-wttrin-location-history.el24
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/test-wttrin-location-history.el b/tests/test-wttrin-location-history.el
index 61b495c..4af8235 100644
--- a/tests/test-wttrin-location-history.el
+++ b/tests/test-wttrin-location-history.el
@@ -113,31 +113,37 @@
;;; wttrin--completion-candidates
(ert-deftest test-wttrin-location-history-normal-candidates-defaults-then-history ()
- "Candidates list defaults first, then history."
+ "Candidates list the sentinel, then defaults, then history."
(test-wttrin-location-history-setup)
(unwind-protect
- (let ((wttrin-default-locations '("Honolulu, HI" "Berkeley, CA"))
+ (let ((wttrin-favorite-location nil)
+ (wttrin-default-locations '("Honolulu, HI" "Berkeley, CA"))
(wttrin--location-history '("Tokyo" "Paris")))
- (should (equal '("Honolulu, HI" "Berkeley, CA" "Tokyo" "Paris")
+ (should (equal (list wttrin--geolocation-sentinel
+ "Honolulu, HI" "Berkeley, CA" "Tokyo" "Paris")
(wttrin--completion-candidates))))
(test-wttrin-location-history-teardown)))
(ert-deftest test-wttrin-location-history-normal-candidates-only-defaults ()
- "With empty history, candidates are just the defaults."
+ "With empty history, candidates are the sentinel then the defaults."
(test-wttrin-location-history-setup)
(unwind-protect
- (let ((wttrin-default-locations '("Honolulu, HI"))
+ (let ((wttrin-favorite-location nil)
+ (wttrin-default-locations '("Honolulu, HI"))
(wttrin--location-history nil))
- (should (equal '("Honolulu, HI") (wttrin--completion-candidates))))
+ (should (equal (list wttrin--geolocation-sentinel "Honolulu, HI")
+ (wttrin--completion-candidates))))
(test-wttrin-location-history-teardown)))
(ert-deftest test-wttrin-location-history-normal-candidates-only-history ()
- "With empty defaults, candidates are just the history."
+ "With empty defaults, candidates are the sentinel then the history."
(test-wttrin-location-history-setup)
(unwind-protect
- (let ((wttrin-default-locations '())
+ (let ((wttrin-favorite-location nil)
+ (wttrin-default-locations '())
(wttrin--location-history '("Tokyo")))
- (should (equal '("Tokyo") (wttrin--completion-candidates))))
+ (should (equal (list wttrin--geolocation-sentinel "Tokyo")
+ (wttrin--completion-candidates))))
(test-wttrin-location-history-teardown)))
;;; wttrin-remove-location-history