branch: externals/osm commit a6335090e9287976a187d3b2159279af44b02b89 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Handle multiple windows --- osm.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osm.el b/osm.el index 8563258a2e..c3ebd2eef9 100644 --- a/osm.el +++ b/osm.el @@ -500,7 +500,14 @@ We need two distinct images which are not `eq' for the display properties.") (let* ((size (expt 2 osm--zoom)) (meter-per-pixel (/ (* 156543.03 (cos (/ (osm--lat) (/ 180.0 float-pi)))) size)) (meter '(1 5 10 50 100 500 1000 5000 10000 50000 100000 500000 1000000 5000000 10000000)) + (windows (or (get-buffer-window-list) (list (frame-root-window)))) + (win-width (cl-loop for w in windows maximize (window-pixel-width w))) + (win-height (cl-loop for w in windows maximize (window-pixel-height w))) (idx 0)) + (setq osm--wx (/ win-width 2) + osm--wy (/ win-height 2) + osm--nx (1+ (ceiling win-width 256)) + osm--ny (1+ (ceiling win-height 256))) (while (and (< idx (1- (length meter))) (< (/ (nth (1+ idx) meter) meter-per-pixel) 100)) (cl-incf idx)) (setq meter (nth idx meter)) @@ -521,10 +528,6 @@ We need two distinct images which are not `eq' for the display properties.") (if (>= meter 1000) (/ meter 1000) meter) (if (>= meter 1000) "km" "m")) '(:eval (osm--queue-info)))) - (setq osm--wx (/ (window-pixel-width) 2) - osm--wy (/ (window-pixel-height) 2) - osm--nx (1+ (ceiling (window-pixel-width) 256)) - osm--ny (1+ (ceiling (window-pixel-height) 256))) (erase-buffer) (dotimes (_j osm--ny) (insert (concat (make-string osm--nx ?\s) "\n"))) @@ -600,8 +603,8 @@ We need two distinct images which are not `eq' for the display properties.") (rename-buffer name 'unique))) (when (or (not (and osm--x osm--y)) at) (osm--set-coordinates (or at (osm--home-coordinates)))) - (osm--update) - (pop-to-buffer (current-buffer))))) + (prog1 (pop-to-buffer (current-buffer)) + (osm--update))))) ;;;###autoload (defun osm-goto (lat lon zoom)