summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-06-08 01:57:45 +0100
committerjao <jao@gnu.org>2022-06-08 01:57:45 +0100
commit434a23285ee71c59413404c6ce1dbf97a061af64 (patch)
tree8046723a9c18479049ec8061f73d3567a83f9cef
parent76bcf1c06adbc3a62cd4a7d3321c25e664530324 (diff)
downloadelibs-434a23285ee71c59413404c6ce1dbf97a061af64.tar.gz
elibs-434a23285ee71c59413404c6ce1dbf97a061af64.tar.bz2
doc:// links for browse-url
-rw-r--r--init.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/init.el b/init.el
index 5c41129..f1772b5 100644
--- a/init.el
+++ b/init.el
@@ -1657,6 +1657,19 @@
(jao-buffer-same-mode '(pdf-view-mode doc-view-mode)
#'jao-afio--goto-docs))
+;; doc:// links for browse-url
+(defun jao-open-doc-url (url &rest _)
+ (when (string-match "doc://\\([^?]+\\)\\(\\?.*\\)?" url)
+ (let ((file (match-string 1 url))
+ (page (when-let* ((qs (match-string 2 url))
+ (_ (> (length qs) 1))
+ (ps (url-parse-query-string (substring qs 1)))
+ (pn (cadr (assoc "page" ps))))
+ (string-to-number pn))))
+ (jao-open-doc (expand-file-name (concat "doc/" file) jao-org-dir) page))))
+
+(add-to-list 'browse-url-handlers (cons "^doc://.+" 'jao-open-doc-url))
+
;;;; epub
(use-package nov
:ensure t