branch: externals/osm
commit 87b46166427b007bc321f8ca407760c0859ab861
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
osm-search: Fix completing-read (Fix #1)
---
osm.el | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/osm.el b/osm.el
index a1209b8533..9b92b1a20f 100644
--- a/osm.el
+++ b/osm.el
@@ -970,7 +970,8 @@ xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'>
(interactive)
;; TODO add search bounded to current viewbox, bounded=1, viewbox=x1,y1,x2,y2
(let* ((search (completing-read
- "Location: " osm--search-history
+ "Location: "
+ (osm--sorted-table osm--search-history)
nil nil nil 'osm--search-history))
(json (json-parse-string
(shell-command-to-string
@@ -993,12 +994,21 @@ xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'>
(selected (or (cdr (assoc
(completing-read
(format "Matches for '%s': " search)
- results nil t nil t)
+ (osm--sorted-table results)
+ nil t)
results))
(error "No selection"))))
(osm-goto (car selected) (cadr selected)
(apply #'osm--boundingbox-to-zoom (cddr selected)))))
+(defun osm--sorted-table (coll)
+ "Sorted completion table from COLL."
+ (lambda (str pred action)
+ (if (eq action 'metadata)
+ '(metadata (display-sort-function . identity)
+ (cycle-sort-function . identity))
+ (complete-with-action action coll str pred))))
+
;;;###autoload
(defun osm-server (server)
"Select tile SERVER."