emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/osm 2841ef6d36 1/3: Generalized command osm-save-url wh


From: ELPA Syncer
Subject: [elpa] externals/osm 2841ef6d36 1/3: Generalized command osm-save-url which can save Geo urls and Elisp links
Date: Sat, 14 Jan 2023 23:58:35 -0500 (EST)

branch: externals/osm
commit 2841ef6d36a6f4b357aca65c0ea7f54b3e022f00
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Generalized command osm-save-url which can save Geo urls and Elisp links
---
 README.org | 22 ++++++++++++++--------
 osm.el     | 35 ++++++++++++++++++++---------------
 2 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/README.org b/README.org
index 48516bc87d..c45705a002 100644
--- a/README.org
+++ b/README.org
@@ -33,7 +33,7 @@ for locations by name and to open and display GPX tracks.
 - Map scale indicator
 - Go to coordinate
 - Search for location by name
-- Org and Elisp link support
+- Org link, Geo url and Elisp link support
 - Bookmarked positions with pins
 - Multiple preconfigured tile servers
 
@@ -65,13 +65,19 @@ Please take a look at the 
[[https://github.com/minad/osm/wiki][wiki]] for additi
       (require 'osm-ol)))
 #+end_src
 
-* Bookmarks, Org and Elisp links
+* Bookmarks, Org links, Geo urls and Elisp links
 
-To store a bookmark press the key ~b~, to store Org/Elisp links press the keys 
~l~
-or ~e~ respectively. You can also use a custom binding, e.g., ~C-c l~. Then 
the link
-can be inserted into an Org buffer with ~C-c C-l~. Bookmarks and Org links can 
be
-created at point with the mouse, see ~osm-bookmark-set-click~ and
-~osm-org-link-click~.
+There exist multiple methods to store the current location.
+
+- ~b~: Create a bookmark of the current location.
+- ~l~: Store an Org link to the current location. The link can the be inserted
+  into an Org buffer with ~C-c C-l~.
+- ~u~: Save the geo url of the current location in the kill ring. The url can 
be
+  inserted in another buffer via ~C-y~.
+- ~C-u u~: Save an Elisp link to the current location in the kill ring.
+
+Bookmarks and Org links can be created at point with the mouse, see
+~osm-bookmark-set-click~ and ~osm-org-link-click~.
 
 **** Org link examples
 
@@ -134,7 +140,7 @@ Key bindings in =osm-mode= buffer:
 - ~x~: =osm-gpx-show= - Show tracks and POIs from GPX file
 - ~X~: =osm-gpx-hide= - Hide overlays from GPX file
 - ~l~: =org-store-link= - Store Org link
-- ~e~: =osm-elisp-link= - Store Elisp link in the kill ring
+- ~u~: =osm-save-url= - Save geo url in the kill ring
 - ~b~: =osm-bookmark-set= - Set bookmark
 - ~n~: =osm-bookmark-rename= - Rename selected bookmark
 - ~j~: =osm-bookmark-jump= - Jump to bookmark
diff --git a/osm.el b/osm.el
index 0c82a515c0..07aa5636d1 100644
--- a/osm.el
+++ b/osm.el
@@ -249,7 +249,7 @@ Should be at least 7 days according to the server usage 
policies."
     ["Server" osm-server t]
     "--"
     ["Org Link" org-store-link t]
-    ["Elisp Link" osm-elisp-link t]
+    ["Geo Url" osm-save-url t]
     ("Bookmark"
      ["Set" osm-bookmark-set t]
      ["Jump" osm-bookmark-jump t]
@@ -310,7 +310,7 @@ Should be at least 7 days according to the server usage 
policies."
   "t" #'osm-goto
   "s" #'osm-search
   "v" #'osm-server
-  "e" #'osm-elisp-link
+  "u" #'osm-save-url
   "l" 'org-store-link
   "b" #'osm-bookmark-set
   "j" #'osm-bookmark-jump
@@ -1569,19 +1569,24 @@ If the prefix argument LUCKY is non-nil take the first 
result and jump there."
                              (error "No server selected"))))))
   (osm--goto nil nil nil server nil nil))
 
-(defun osm-elisp-link ()
-  "Store coordinates as an Elisp link in the kill ring."
-  (interactive)
+(defun osm-save-url (&optional arg)
+  "Save coordinates as url in the kill ring.
+If prefix ARG is given, store url as Elisp expression."
+  (interactive "P")
   (osm--barf-unless-osm)
-  (pcase-let* ((`(,lat ,lon ,loc) (osm--fetch-location-data 'osm-link "New 
Elisp Link"))
-               (link (format "(osm %.6f %.6f %s%s%s)"
-                             lat lon osm--zoom
-                             (if (eq osm-server (default-value 'osm-server))
-                                 ""
-                               (format " '%s" osm-server))
-                             (if loc (format " %S" loc) ""))))
-    (kill-new link)
-    (message "Stored in the kill ring: %s" link)))
+  (pcase-let* ((`(,lat ,lon ,loc) (osm--fetch-location-data 'osm-link "New 
Link"))
+               (server (and (not (eq osm-server (default-value 'osm-server))) 
osm-server))
+               (url (if arg
+                         (format "(osm %.6f %.6f %s%s%s)"
+                                 lat lon osm--zoom
+                                 (if server (format " '%s" osm-server) "")
+                                 (if loc (format " %S" loc) ""))
+                       (format "geo:%.6f,%.6f;z=%s%s%s"
+                               lat lon osm--zoom
+                               (if server (format ";s=%s" osm-server) "")
+                               (if loc (format " (%s)" loc) "")))))
+    (kill-new url)
+    (message "Stored in the kill ring: %s" url)))
 
 ;;;###autoload
 (add-to-list 'browse-url-default-handlers '("\\`geo:" . osm))
@@ -1589,7 +1594,7 @@ If the prefix argument LUCKY is non-nil take the first 
result and jump there."
 (dolist (sym (list #'osm-center #'osm-up #'osm-down #'osm-left #'osm-right
                    #'osm-up-up #'osm-down-down #'osm-left-left 
#'osm-right-right
                    #'osm-zoom-out #'osm-zoom-in #'osm-bookmark-set 
#'osm-gpx-hide
-                   #'osm-elisp-link))
+                   #'osm-save-url))
   (put sym 'command-modes '(osm-mode)))
 (dolist (sym (list #'osm-mouse-drag #'osm-transient-click #'osm-org-link-click
                    #'osm-poi-click #'osm-bookmark-set-click 
#'osm-bookmark-select-click))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]