diff options
author | jao <jao@gnu.org> | 2022-06-08 01:57:45 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-06-08 01:57:45 +0100 |
commit | 434a23285ee71c59413404c6ce1dbf97a061af64 (patch) | |
tree | 8046723a9c18479049ec8061f73d3567a83f9cef | |
parent | 76bcf1c06adbc3a62cd4a7d3321c25e664530324 (diff) | |
download | elibs-434a23285ee71c59413404c6ce1dbf97a061af64.tar.gz elibs-434a23285ee71c59413404c6ce1dbf97a061af64.tar.bz2 |
doc:// links for browse-url
-rw-r--r-- | init.el | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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 |