[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/osm 88fdaf7f55 1/4: Elisp link support (#8)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/osm 88fdaf7f55 1/4: Elisp link support (#8) |
Date: |
Wed, 16 Mar 2022 22:57:38 -0400 (EDT) |
branch: externals/osm
commit 88fdaf7f55a410d490e24a3596bb537b51ee93f9
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: GitHub <noreply@github.com>
Elisp link support (#8)
* Add osm-elisp-link
* Add osm function
* README: Document Elisp links
See #7 for the discussion.
---
README.org | 24 ++++++++++++++++++------
osm.el | 28 ++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/README.org b/README.org
index 43cefdd777..b6e60edc05 100644
--- a/README.org
+++ b/README.org
@@ -25,7 +25,7 @@ rendering is ©
[[https://opentopomap.org/about][OpenTopoMap]], licensed under t
- Map scale indicator
- Go to coordinate
- Search for location by name
-- Org link support
+- Org and Elisp link support
- Bookmarked positions with pins
- Multiple preconfigured tile servers
@@ -57,12 +57,13 @@ take a look at the
[[https://github.com/minad/osm/wiki][wiki]] for additional co
* Bookmarks and Org links
-To store a bookmark press the key ~b~, to store Org links press the key ~l~.
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~.
+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~.
-Examples:
+Org link examples:
- [[osm:opentopomap:41.869560826994544,12.45849609375,6][Italia, 41.87° 12.46°
OpenTopoMap]]
- [[osm:51.48950698022105,-0.144195556640625,11][London, England, 51.49°
-0.14°]]
@@ -70,6 +71,16 @@ Examples:
- [[osm:stamen-watercolor:40.72956780913898,-73.97918701171875,12][New York,
United States, 40.73° -73.98° Stamen Watercolor]]
- [[osm:opentopomap:27.961656050984658,86.89224243164062,13][Mount Everest,
27.96° 86.89° OpenTopoMap]]
+Elisp link examples:
+
+#+begin_src emacs-lisp
+ (osm 41.869560826994544 12.45849609375 6 opentopomap "Lazio, Italia")
+ (osm 51.48950698022105 -0.144195556640625 11 "London, Greater London,
England, SW1A 2DX, United Kingdom")
+ (osm 55.686875255964424 12.569732666015625 12 cyclosm "København, Københavns
Kommune, Region Hovedstaden, 1357, Danmark")
+ (osm 40.72956780913898 -73.97918701171875 12 stamen-watercolor "New York
County, New York, United States")
+ (osm 27.961656050984658 86.89224243164062 13 opentopomap "Khumjung,
Khumbupasanglahmu, सोलुखुम्बु, Province #1, Nepal")
+#+end_src
+
* Commands and Key Bindings
Top-level commands:
@@ -99,6 +110,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
- ~b~: =osm-bookmark-set= - Set bookmark
- ~j~: =osm-bookmark-jump= - Jump to bookmark
- ~q~: =quit-window= - Close buffer and window
diff --git a/osm.el b/osm.el
index bc6eede831..e78d1a211e 100644
--- a/osm.el
+++ b/osm.el
@@ -240,6 +240,7 @@ Should be at least 7 days according to the server usage
policies."
(define-key map "t" #'osm-goto)
(define-key map "s" #'osm-search)
(define-key map "v" #'osm-server)
+ (define-key map "e" #'osm-elisp-link)
(define-key map "l" 'org-store-link)
(define-key map "b" #'osm-bookmark-set)
(define-key map "j" #'osm-bookmark-jump)
@@ -1153,7 +1154,16 @@ xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'>
(unless (and (numberp lat) (numberp lon) (numberp zoom))
(error "Invalid coordinate"))
(list lat lon zoom)))
- (osm--goto (list lat lon zoom) nil))
+ (osm--goto (list lat lon zoom) nil)
+ nil)
+
+;;;###autoload
+(defmacro osm (lat lon zoom &optional server comment)
+ "Go to LAT/LON/ZOOM.
+Optionally specify a SERVER and a COMMENT."
+ (ignore comment)
+ (when (stringp server) (setq server nil)) ;; Ignore comment
+ `(osm--goto (list ,lat ,lon ,zoom) ,(and (symbolp server) `',server)))
;;;###autoload
(defun osm-bookmark-jump (bm)
@@ -1385,9 +1395,23 @@ xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'>
(error "No server selected"))))))
(osm--goto nil server))
+(defun osm-elisp-link ()
+ "Store coordinates as an Elisp link in the kill ring."
+ (interactive)
+ (pcase-let* ((`(,lat ,lon ,name) (osm--location-data 'osm-org-link "Elisp
link"))
+ (link (format "(osm %s %s %s%s%s)"
+ lat lon osm--zoom
+ (if (eq osm-server (default-value 'osm-server))
+ ""
+ (format " '%s" osm-server))
+ (if name (format " %S" name) ""))))
+ (kill-new link)
+ (message "Stored link in the kill ring")))
+
(dolist (sym (list #'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-zoom-out #'osm-zoom-in #'osm-bookmark-set
#'osm-gpx-hide
+ #'osm-elisp-link))
(put sym 'command-modes '(osm-mode)))
(dolist (sym (list #'osm-mouse-drag #'osm-center-click #'osm-org-link-click
#'osm-poi-click #'osm-bookmark-set-click
#'osm-bookmark-select-click))