diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-26 10:53:18 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-26 10:53:18 -0400 |
| commit | 55ee8158a1f85bb532a24d752f9ef409192a924c (patch) | |
| tree | 417ee476e2dfa75c75e2ce2a4e99f77e36ccdac2 /tests/test-wttrin-use-current-location.el | |
| parent | 7027cccea9eb7170ea0f08e1def3f979f2e59932 (diff) | |
| download | emacs-wttrin-55ee8158a1f85bb532a24d752f9ef409192a924c.tar.gz emacs-wttrin-55ee8158a1f85bb532a24d752f9ef409192a924c.zip | |
feat: add named-locations directory with display names
A saved location carries a display name distinct from its query target ("Mom's House" maps to coordinates or an address), stored in a savehist-persisted wttrin-saved-locations alist. The name shows everywhere the place appears (picker, buffer header, mode-line tooltip) while wttr.in is still queried by the target.
Management commands wttrin-save-location, wttrin-rename-location, and wttrin-remove-location edit the directory, with refuse-on-collision rename and a favorite-fallback warning on remove. In the weather buffer, s/r/x reach those commands and d names a detected location before promoting it to the default. The footer is two columns: a "This view" column (another, refresh, quit) and a "Saved locations" column (save, make default, rename, remove). The buffer anchors to the top so the forecast isn't scrolled out of view in a short window.
The mode-line follows favorite changes immediately rather than waiting for the next scheduled fetch, and its hover tooltip shows the saved name instead of the raw query. History holds named entries only: raw coordinate detections and saved names stay out of it.
Diffstat (limited to 'tests/test-wttrin-use-current-location.el')
| -rw-r--r-- | tests/test-wttrin-use-current-location.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-wttrin-use-current-location.el b/tests/test-wttrin-use-current-location.el index 2b08448..4b61657 100644 --- a/tests/test-wttrin-use-current-location.el +++ b/tests/test-wttrin-use-current-location.el @@ -52,6 +52,27 @@ (should (equal "Berkeley, CA" wttrin-favorite-location))) (test-wttrin-use-current-location-teardown))) +(ert-deftest test-wttrin-use-current-location-normal-confirm-refreshes-mode-line () + "Normal: confirming refreshes the mode-line so it switches to the current +location immediately rather than at the next scheduled fetch." + (test-wttrin-use-current-location-setup) + (setq wttrin-favorite-location "Berkeley, CA") + (unwind-protect + (let ((wttrin-geolocation-enabled t) + (wttrin-mode-line-mode t) + (wttrin--location-history nil) + (fetched nil)) + (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t)) + ((symbol-function 'message) (lambda (&rest _) nil)) + ((symbol-function 'wttrin--mode-line-fetch-weather) + (lambda () (setq fetched t))) + ((symbol-function 'wttrin--mode-line-set-placeholder) + (lambda () nil))) + (wttrin-use-current-location)) + (should (eq t wttrin-favorite-location)) + (should fetched)) + (test-wttrin-use-current-location-teardown))) + ;;; Boundary / Error Cases (ert-deftest test-wttrin-use-current-location-boundary-disabled-no-prompt-no-set () |
