summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2026-01-07 22:37:28 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2026-01-07 22:48:09 +0100
commit1e67caefebef3bc05bb19e74aaf412036a3759b6 (patch)
tree5ec5bb427afb62d1d8e51ac259cec6debda6bdb4
parenta903ab0ad87b5db2d31d0e0450ec54ca3e841dbc (diff)
Indentation & formatting
-rw-r--r--README.org8
-rw-r--r--osm.el83
2 files changed, 41 insertions, 50 deletions
diff --git a/README.org b/README.org
index 5fd2421..916b6e1 100644
--- a/README.org
+++ b/README.org
@@ -19,14 +19,14 @@ viewer fetches the map tiles in parallel from tile servers via the =curl= progra
The package comes with a list of multiple preconfigured tile servers. You can
bookmark your favorite locations using regular Emacs bookmarks or create links
from Org files to locations. Furthermore the package provides commands to search
-for locations, or plan routes by name and to open and display GPX/TCX tracks.
+for locations, or plan routes by name and to open and display GPX or TCX tracks.
#+toc: headlines 8
* Features
- Responsive, zoomable and movable map display
-- Display of tracks and POIs from GPX/TCX file
+- Display of tracks and POIs from GPX or TCX file
- Parallel fetching of tiles with curl
- Moving in large and small steps
- Mouse support (dragging, clicking, menu)
@@ -140,7 +140,7 @@ initiate a search.
- ~u~: =osm-url= - Go to Geo URL, OpenStreetMap.org or Google Maps URL.
- ~v~: =osm-server= - Select server
- ~j~: =osm-jump= - Jump to pin (bookmark or POI)
-- ~f~: =osm-open= - Open GPX/TCX file in map viewer
+- ~f~: =osm-open= - Open GPX or TCX file in map viewer
Some additional key bindings are available in Osm buffers:
@@ -156,7 +156,7 @@ Some additional key bindings are available in Osm buffers:
- ~d~, ~DEL~: =osm-delete= - Delete selected pin (bookmark or way point)
- ~n~: =osm-rename= - Rename selected pin
- ~c~: =osm-center= - Center to currently selected pin
-- ~F~, ~R~: =osm-hide= - Hide GPX/TCX file or route
+- ~F~, ~R~: =osm-hide= - Hide GPX or TCX file or route
- ~l~: =org-store-link= - Store Org link
- ~u~: =osm-save-url= - Save geo url in the kill ring
- ~b~: =osm-bookmark-set= - Set bookmark
diff --git a/osm.el b/osm.el
index 5ca63cf..330dcf2 100644
--- a/osm.el
+++ b/osm.el
@@ -35,7 +35,7 @@
;; locations using regular Emacs bookmarks or create links from Org files
;; to locations. Furthermore the package provides commands to measure
;; distances, search for locations and routes by name and to open and
-;; display GPX/TCX tracks.
+;; display GPX or TCX tracks.
;; osm.el requires Emacs 29 and depends on the external `curl' program.
;; Emacs must be built with libxml, libjansson, librsvg, libjpeg, libpng
@@ -599,8 +599,8 @@ Local per buffer since the overlays depend on the zoom level.")
(when (equal status "200")
(ignore-errors (rename-file file (string-remove-suffix ".tmp" file) t))
(osm--each
- (when (and (= osm--zoom zoom) (eq osm-server server))
- (osm--display-tile x y (osm--get-tile x y)))))
+ (when (and (= osm--zoom zoom) (eq osm-server server))
+ (osm--display-tile x y (osm--get-tile x y)))))
(cl-callf2 delete (list server zoom x y) osm--download-active)
(delete-file file)))
output)
@@ -622,8 +622,8 @@ Local per buffer since the overlays depend on the zoom level.")
(push job osm--download-active)
(cl-incf count)))
(osm--each
- (dolist (job jobs)
- (cl-callf2 delq job osm--download-queue)))
+ (dolist (job jobs)
+ (cl-callf2 delq job osm--download-queue)))
(cons `("curl" "--disable" "--write-out" "%{http_code} %{filename_effective}\n"
,@(split-string-and-unquote osm-curl-options) ,@(nreverse args))
jobs)))
@@ -657,8 +657,8 @@ Local per buffer since the overlays depend on the zoom level.")
(force-mode-line-update t)
(osm--download)))
(alist-get server osm--download-processes))
- (force-mode-line-update t)
- (osm--download))))
+ (force-mode-line-update t)
+ (osm--download))))
(defun osm-mouse-drag (event)
"Handle drag EVENT."
@@ -968,13 +968,13 @@ Local per buffer since the overlays depend on the zoom level.")
(pcase-let ((`(,lat ,lon ,zoom) (bookmark-prop-get bm 'coordinates)))
(funcall fun 'osm-bookmark lat lon zoom (car bm))))
(cl-loop for (dname id segs waypoints) in osm--datasets do
- (when-let* ((start (caar segs)))
- (funcall fun id (car start) (cdr start) 10
- (propertize dname 'osm-dataset dname)))
- (cl-loop for (lat lon name) in waypoints do
- (funcall fun id lat lon 15
- (propertize (format "%s [%s]" name dname)
- 'osm-dataset dname))))
+ (when-let* ((start (caar segs)))
+ (funcall fun id (car start) (cdr start) 10
+ (propertize dname 'osm-dataset dname)))
+ (cl-loop for (lat lon name) in waypoints do
+ (funcall fun id lat lon 15
+ (propertize (format "%s [%s]" name dname)
+ 'osm-dataset dname))))
(cl-loop for (lat lon name) in osm--track do
(funcall fun 'osm-track lat lon 15 name)))
@@ -1188,8 +1188,8 @@ xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
(clear-image-cache t) ;; Make absolutely sure that the tiles are redrawn.
(setq osm--tile-cache nil)
(osm--each
- (setq osm--overlays nil)
- (osm--update)))
+ (setq osm--overlays nil)
+ (osm--update)))
(defun osm--header-button (text action)
"Format header line button with TEXT and ACTION."
@@ -1804,42 +1804,34 @@ See `osm-search-server' and `osm-search-language' for customization."
;;;###autoload
(defun osm-open (file)
- "Show the tracks of GPX/TCX FILE in an `osm-mode' buffer."
+ "Show the tracks of GPX or TCX FILE in an `osm-mode' buffer."
(interactive "fGPX or TCX file: ")
(osm--check-libraries)
(let ((dom (with-temp-buffer
(insert-file-contents file)
- (libxml-parse-xml-region (point-min) (point-max)))))
-
- (cond
- ((not dom)
- (error "Not an XML file"))
-
- ((eq 'TrainingCenterDatabase (dom-tag dom))
- (osm--add-dataset
- (abbreviate-file-name file)
- 'osm-file
- (osm--tcx-track dom)
- (osm--tcx-waypoints dom)))
-
- (t
+ (libxml-parse-xml-region (point-min) (point-max))))
+ (file (abbreviate-file-name file)))
+ (if (eq 'TrainingCenterDatabase (dom-tag dom))
+ (osm--add-dataset file 'osm-file
+ (osm--tcx-track dom)
+ (osm--tcx-waypoints dom))
(unless (eq 'gpx (dom-tag dom))
(setq dom (dom-child-by-tag dom 'gpx)))
(unless (and dom (eq 'gpx (dom-tag dom)))
- (error "Not a GPX file"))
+ (error "Not a GPX or TCX file"))
+ (osm--add-dataset file 'osm-file
+ (osm--gpx-track dom)
+ (osm--gpx-waypoints dom)))))
- (osm--add-dataset
- (abbreviate-file-name file)
- 'osm-file
- (osm--gpx-track dom)
- (osm--gpx-waypoints dom))))))
+;; Prevent deprecation warning
+(defalias 'osm--dom-text 'dom-text)
-(defsubst osm--tcx-position (position)
- "Convert POSITION to a cons of (lat . lon)."
- (let* ((lat (dom-child-by-tag position 'LatitudeDegrees))
- (lon (dom-child-by-tag position 'LongitudeDegrees)))
- (cons (string-to-number (dom-text lat))
- (string-to-number (dom-text lon)))))
+(defsubst osm--tcx-position (pos)
+ "Convert POS to a cons of (lat . lon)."
+ (let ((lat (dom-child-by-tag pos 'LatitudeDegrees))
+ (lon (dom-child-by-tag pos 'LongitudeDegrees)))
+ (cons (string-to-number (osm--dom-text lat))
+ (string-to-number (osm--dom-text lon)))))
(defun osm--tcx-waypoints (dom)
"Return waypoints contained in tcx DOM."
@@ -1850,7 +1842,7 @@ See `osm-search-server' and `osm-search-language' for customization."
for pt in (dom-by-tag course 'CoursePoint)
for pos = (osm--tcx-position (dom-child-by-tag pt 'Position))
for name = (dom-by-tag pt 'Name)
- collect (list (car pos) (cdr pos) (dom-text name)))))
+ collect (list (car pos) (cdr pos) (osm--dom-text name)))))
(defun osm--tcx-track (dom)
"Return track points contained in tcx DOM."
@@ -1887,8 +1879,7 @@ See `osm-search-server' and `osm-search-language' for customization."
if (eq (dom-tag pt) 'wpt) collect
(list (string-to-number (dom-attr pt 'lat))
(string-to-number (dom-attr pt 'lon))
- (with-no-warnings
- (dom-text (dom-child-by-tag pt 'name))))))
+ (osm--dom-text (dom-child-by-tag pt 'name)))))
(defun osm--add-dataset (name id track waypoints)
"Add dataset with NAME and ID consisting of TRACK and WAYPOINTS."