diff options
-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 |