From 06143c61c3782b24c738587ae5e1f427ceb0518c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 26 Jun 2026 12:52:48 -0400 Subject: fix: keep saved locations and search history disjoint Pressing d cleaned the location from history, but saving with s did not. A place saved under a friendly name kept its raw query as a separate history candidate, and removing the saved entry let that query resurface in the picker. wttrin-save-location now drops the saved name and its query from history, and wttrin-remove-location drops both the removed name and its query (captured before removal). A new wttrin--drop-from-location-history helper does the work. A place now lives in the directory or in history, never both. --- wttrin.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'wttrin.el') diff --git a/wttrin.el b/wttrin.el index b55e0cc..f64af7f 100644 --- a/wttrin.el +++ b/wttrin.el @@ -618,6 +618,15 @@ promoted to most-recent, and the list is trimmed to (butlast wttrin--location-history (- (length wttrin--location-history) max))))))) +(defun wttrin--drop-from-location-history (&rest locations) + "Remove each non-nil string in LOCATIONS from `wttrin--location-history'. +Keeps the directory and the history disjoint: a place lives in one or the +other, never both." + (dolist (location locations) + (when (and location (stringp location)) + (setq wttrin--location-history + (delete location wttrin--location-history))))) + (defun wttrin--saved-locations () "Return `wttrin-saved-locations' as a clean list of (NAME . QUERY) pairs. Skips malformed entries — non-cons, a non-string name or query, or an empty @@ -808,6 +817,7 @@ address, else the query. Saving an existing name updates its query." (message "Cancelled") (let ((existing (assoc (string-trim name) (wttrin--saved-locations))) (saved (wttrin--put-saved-location name query))) + (wttrin--drop-from-location-history saved query) (message (if existing "Updated %s" "Saved %s") saved)))) (defun wttrin-rename-location (old new) @@ -847,7 +857,9 @@ When NAME is the favorite, it is left as a literal query with a warning." ((not (assoc name (wttrin--saved-locations))) (user-error "No saved location named %s" name)) ((yes-or-no-p (format "Remove saved location \"%s\"? " name)) - (wttrin--remove-saved-location name) + (let ((query (cdr (assoc name (wttrin--saved-locations))))) + (wttrin--remove-saved-location name) + (wttrin--drop-from-location-history name query)) (if (equal wttrin-favorite-location name) (progn (when (bound-and-true-p wttrin-mode-line-mode) -- cgit v1.2.3