branch: externals/osm commit e6adbe7162e6eb870f036bb18a152846b7b26976 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
osm-search: Improve behavior with default completion - Unbind SPC minibuffer-complete-word from search prompt completion - Show location matches immediately --- CHANGELOG.org | 1 + osm.el | 47 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index fb27d41839..8ac25780c7 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -7,6 +7,7 @@ - Compatibility with =pixel-scroll-precision-mode=. - Update list of servers. - Add =osm-add-server= utility function with error checking. +- =osm-search=: Improve UI if default completions buffer is used. * Version 0.13 (2023-07-02) diff --git a/osm.el b/osm.el index fa89dde651..a1a76be4c8 100644 --- a/osm.el +++ b/osm.el @@ -1466,21 +1466,40 @@ When called interactively, call the function `osm-home'." "Globally search for NEEDLE and display the map. If the prefix argument LUCKY is non-nil take the first result and jump there." (interactive - (list (completing-read "Location: " - (osm--sorted-table osm--search-history) - nil nil nil 'osm--search-history) - current-prefix-arg)) + (list + (minibuffer-with-setup-hook + (lambda () + (when (and (eq completing-read-function #'completing-read-default) + (not (bound-and-true-p vertico-mode))) + ;; Override dreaded `minibuffer-complete-word' for default + ;; completion. When will this keybinding finally get removed from + ;; default completion? + (use-local-map (make-composed-keymap + (define-keymap "SPC" nil) + (current-local-map))))) + (completing-read "Location: " + (osm--sorted-table osm--search-history) + nil nil nil 'osm--search-history)) + current-prefix-arg)) ;; TODO add search bounded to current viewbox, bounded=1, viewbox=x1,y1,x2,y2 - (let* ((results (or (osm--search needle) (error "No results"))) - (selected (or - (and (or lucky (not (cdr results))) (car results)) - (assoc - (completing-read - (format "Matches for '%s': " needle) - (osm--sorted-table results) - nil t) - results) - (error "No selection")))) + (let* ((results (or (osm--search needle) (error "No results for `%s'" needle))) + (selected + (or + (and (or lucky (not (cdr results))) (car results)) + (assoc + (minibuffer-with-setup-hook + (lambda () + (when (and (eq completing-read-function #'completing-read-default) + (not (bound-and-true-p vertico-mode)) + (not (bound-and-true-p icomplete-mode))) + ;; Show matches immediately for default completion. + (minibuffer-completion-help))) + (completing-read + (format "Matches for '%s': " needle) + (osm--sorted-table results) + nil t)) + results) + (error "No selection")))) (osm--goto (cadr selected) (caddr selected) (apply #'osm--boundingbox-to-zoom (cdddr selected)) nil 'osm-transient (car selected))))