[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/osm fce584fbae 60/77: Add osm-bookmark-delete-click
From: |
ELPA Syncer |
Subject: |
[elpa] externals/osm fce584fbae 60/77: Add osm-bookmark-delete-click |
Date: |
Mon, 7 Mar 2022 08:58:08 -0500 (EST) |
branch: externals/osm
commit fce584fbaeb243477815d280544d711d9b5b02b7
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add osm-bookmark-delete-click
---
README.org | 1 +
osm.el | 35 ++++++++++++++++++++++++++++-------
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/README.org b/README.org
index 40a74866d5..0154fc4edd 100644
--- a/README.org
+++ b/README.org
@@ -68,6 +68,7 @@ Key bindings in =osm-mode= buffer:
- ~<mouse-1>~: =osm-zoom-click= - Zoom to point
- ~<mouse-2>~: =osm-org-link-click= - Store point as Org link
- ~<mouse-3>~: =osm-bookmark-set-click= - Store point as bookmark
+- ~<S-mouse-3>~: =osm-bookmark-delete-click= - Delete bookmark at point
- ~g~: =osm-goto= - Go to location
- ~h~: =osm-home= - Go to home location
- ~s~: =osm-search= - Search for location
diff --git a/osm.el b/osm.el
index 9753c7e700..55e0d2efc7 100644
--- a/osm.el
+++ b/osm.el
@@ -138,6 +138,7 @@ Should be at least 7 days according to the server usage
policies."
(define-key map [mouse-1] #'osm-zoom-click)
(define-key map [mouse-2] #'osm-org-link-click)
(define-key map [mouse-3] #'osm-bookmark-set-click)
+ (define-key map [S-mouse-3] #'osm-bookmark-delete-click)
(define-key map [drag-mouse-1] #'osm-drag)
(define-key map [up] #'osm-up)
(define-key map [down] #'osm-down)
@@ -369,6 +370,23 @@ Should be at least 7 days according to the server usage
policies."
(osm--y (+ osm--y (- y osm--wy))))
(osm-bookmark-set)))
+(defun osm-bookmark-delete-click (event)
+ "Delete bookmark at position of click EVENT."
+ (interactive "@e")
+ (pcase-let* ((`(,x . ,y) (posn-x-y (event-start event)))
+ (x (+ osm--x (- x osm--wx)))
+ (y (+ osm--y (- y osm--wy)))
+ (min most-positive-fixnum)
+ (found nil))
+ (cl-loop for (p q . name) in osm--bookmark-positions
+ for d = (+ (* (- p x) (- p x)) (* (- q y) (- q y)))
+ if (and (< d 2500) (< d min)) do
+ (setq min d found name))
+ (unless found
+ (error "No bookmark at point"))
+ (bookmark-delete found)
+ (osm--revert)))
+
(defun osm-org-link-click (event)
"Store link at position of click EVENT."
(interactive "@e")
@@ -502,13 +520,13 @@ Should be at least 7 days according to the server usage
policies."
(let* ((coord (bookmark-prop-get bm 'coordinates))
(px (osm--lon-to-x (cadr coord) osm--zoom))
(py (osm--lat-to-y (car coord) osm--zoom)))
- (cons px py)))))
+ `(,px ,py . ,(car bm))))))
(defun osm--bookmarks-at (x y)
"Get bookmarks at X/Y."
;; TODO Optimized k2 tree?
(setq x (* x 256) y (* y 256))
- (cl-loop for (p . q) in (osm--bookmark-positions)
+ (cl-loop for (p q . _name) in osm--bookmark-positions
if (and (>= p (- x 100)) (< p (+ x 256 100))
(>= q (- y 100)) (< q (+ y 256 100)))
collect (cons (- p x) (- q y))))
@@ -578,10 +596,12 @@ xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'>
" ")))
(defun osm--revert (&rest _)
- "Revert buffer."
- (when (eq major-mode #'osm-mode)
- (when osm--tiles (clrhash osm--tiles))
- (osm--update)))
+ "Revert osm buffers."
+ (dolist (buf (buffer-list))
+ (when (eq (buffer-local-value 'major-mode buf) #'osm-mode)
+ (with-current-buffer buf
+ (when osm--tiles (clrhash osm--tiles))
+ (osm--update)))))
(defun osm--resize (&rest _)
"Resize buffer."
@@ -845,7 +865,8 @@ MSG is a message prefix string."
#'osm-up-up #'osm-down-down #'osm-left-left
#'osm-right-right
#'osm-zoom-out #'osm-zoom-in #'osm-bookmark-set
#'osm-bookmark-jump))
(put sym 'command-modes '(osm-mode)))
-(dolist (sym (list #'osm-drag #'osm-zoom-click #'osm-bookmark-set-click
#'osm-org-link-click))
+(dolist (sym (list #'osm-drag #'osm-zoom-click #'osm-org-link-click
+ #'osm-bookmark-set-click #'osm-bookmark-delete-click))
(put sym 'completion-predicate #'ignore))
(provide 'osm)
- [elpa] externals/osm 92fb0c72dd 62/77: Add osm-bookmark-delete, (continued)
- [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, 2022/03/07
- [elpa] externals/osm fce584fbae 60/77: Add osm-bookmark-delete-click,
ELPA Syncer <=
- [elpa] externals/osm 591d783065 36/77: README: Improve documentation, ELPA Syncer, 2022/03/07