[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/osm 585346b5e0 53/77: Improve bookmark command
From: |
ELPA Syncer |
Subject: |
[elpa] externals/osm 585346b5e0 53/77: Improve bookmark command |
Date: |
Mon, 7 Mar 2022 08:58:07 -0500 (EST) |
branch: externals/osm
commit 585346b5e001fb32847f51cf8c1043f57396f90a
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Improve bookmark command
---
osm.el | 56 ++++++++++++++++++++++++++------------------------------
1 file changed, 26 insertions(+), 30 deletions(-)
diff --git a/osm.el b/osm.el
index e6b9e23cb6..ff22173f7d 100644
--- a/osm.el
+++ b/osm.el
@@ -172,9 +172,6 @@ We need two distinct images which are not `eq' for the
display properties.")
(defvar osm--clean-cache 0
"Last time the tile cache was cleaned.")
-(defvar osm--location-name nil
- "Location name used by `osm--bookmark-name'.")
-
(defvar-local osm--url-index 0
"Current url index to query the servers in a round-robin fashion.")
@@ -595,13 +592,13 @@ We need two distinct images which are not `eq' for the
display properties.")
(defun osm--org-link-data ()
"Return Org link data."
- (let ((osm--location-name (osm--location-name "Org link")))
- (list (osm--lat) (osm--lon) osm--zoom
- (and (not (eq osm-server (default-value 'osm-server))) osm-server)
- (let ((name (string-remove-prefix "osm: " (osm--bookmark-name))))
- (if (eq osm-server (default-value 'osm-server))
- (string-remove-suffix (concat " " (osm--server-property
:name)) name)
- name)))))
+ (list (osm--lat) (osm--lon) osm--zoom
+ (and (not (eq osm-server (default-value 'osm-server))) osm-server)
+ (let ((name (string-remove-prefix
+ "osm: " (osm--bookmark-name (osm--location-name "Org
link")))))
+ (if (eq osm-server (default-value 'osm-server))
+ (string-remove-suffix (concat " " (osm--server-property :name))
name)
+ name))))
(defun osm--buffer-name ()
"Return buffer name."
@@ -609,10 +606,10 @@ We need two distinct images which are not `eq' for the
display properties.")
(osm--lat) (osm--lon) osm--zoom
(osm--server-property :name)))
-(defun osm--bookmark-name ()
- "Return bookmark name."
+(defun osm--bookmark-name (&optional loc)
+ "Return bookmark name with optional LOC name."
(format "osm: %s%.2f° %.2f° Z%s %s"
- (if osm--location-name (concat osm--location-name ", ") "")
+ (if loc (concat loc ", ") "")
(osm--lat) (osm--lon) osm--zoom
(osm--server-property :name)))
@@ -687,28 +684,27 @@ We need two distinct images which are not `eq' for the
display properties.")
(defun osm-bookmark ()
"Create osm bookmark."
(interactive)
- (let ((osm--location-name (osm--location-name "Bookmark")))
- (call-interactively #'bookmark-set)))
+ (let* ((def (osm--bookmark-name (osm--location-name "Bookmark")))
+ (name (read-from-minibuffer "Bookmark name: " def nil nil nil def)))
+ (bookmark-set name)
+ (message "Stored bookmark: %s" name)))
(defun osm--location-name (msg)
"Fetch location name of current position.
MSG is a message prefix string."
(message "%s: Fetching name of %.2f %.2f..." msg (osm--lat) (osm--lon))
- (let ((name
- (ignore-errors
- (alist-get
- 'display_name
- (json-parse-string
- (shell-command-to-string
- (concat
- "curl -f -s "
- (shell-quote-argument
- (format
"https://nominatim.openstreetmap.org/reverse?format=json&zoom=%s&lon=%s&lat=%s"
- (min 18 (max 3 osm--zoom)) (osm--lon) (osm--lat)))))
- :array-type 'list
- :object-type 'alist)))))
- (message "%s" (or name "No name found"))
- name))
+ (ignore-errors
+ (alist-get
+ 'display_name
+ (json-parse-string
+ (shell-command-to-string
+ (concat
+ "curl -f -s "
+ (shell-quote-argument
+ (format
"https://nominatim.openstreetmap.org/reverse?format=json&zoom=%s&lon=%s&lat=%s"
+ (min 18 (max 3 osm--zoom)) (osm--lon) (osm--lat)))))
+ :array-type 'list
+ :object-type 'alist))))
;;;###autoload
(defun osm-search ()
- [elpa] externals/osm db20223911 27/77: Minor cleanup, (continued)
- [elpa] externals/osm db20223911 27/77: Minor cleanup, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 92fb0c72dd 62/77: Add osm-bookmark-delete, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 6f14067777 26/77: add mwheel scroll functions, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 9ffe9592ba 55/77: Simplify code, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 28afc293f9 47/77: Improve bookmark and Org link support, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 5af320c57f 10/77: Add Stamen servers, support jpeg tiles, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 593b95a50c 17/77: Add more maps, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 305aea000b 03/77: Use cl-loop, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 5f002af18c 24/77: Fix file extraction, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 5f47b77d20 45/77: Move predeclared variables, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 585346b5e0 53/77: Improve bookmark command,
ELPA Syncer <=
- [elpa] externals/osm fce584fbae 60/77: Add osm-bookmark-delete-click, ELPA Syncer, 2022/03/07
- [elpa] externals/osm 591d783065 36/77: README: Improve documentation, ELPA Syncer, 2022/03/07