From 50d1776b7f98d5833b4e3f9e65dce8e9d452c05e Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 3 Feb 2021 04:04:16 +0000 Subject: jao-org-links: move to afio ws on opening doc: link --- lib/org/jao-org-links.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/org/jao-org-links.el b/lib/org/jao-org-links.el index 7d9cb55..21bf27c 100644 --- a/lib/org/jao-org-links.el +++ b/lib/org/jao-org-links.el @@ -4,13 +4,16 @@ (defvar jao-org--sink-dir "./") (defvar jao-org-open-pdf-fun 'jao-org--pdf-tools-open) -(defun jao-org--pdf-tools-open (path page &optional height) - (org-open-file path 1) - (pdf-view-goto-page page) +(defun jao-org--pdf-go (page height) + (when page (pdf-view-goto-page page)) (when height (image-set-window-vscroll (round (/ (* height (cdr (pdf-view-image-size))) (frame-char-height)))))) +(defun jao-org--pdf-tools-open (path page &optional height) + (org-open-file path 1) + (jao-org--pdf-go path page)) + (defun jao-org--pdf-open (path page &optional height) (funcall (or jao-org-open-pdf-fun 'jao-org--pdf-tools-open) path page height)) @@ -26,9 +29,9 @@ (jao-org--pdf-open path page height))) ((string-match "\\(.*\\)::\\([0-9]+\\)$" link) (let* ((path (match-string 1 link)) - (page (string-to-number (match-string 2 link)))) + (page (max 1 (string-to-number (match-string 2 link))))) (jao-org--pdf-open path page))) - (t (org-open-file link 1)))) + (t (jao-org--pdf-open link nil)))) (defun jao-org-links--follow-doc (link) (let* ((full-link (concat org-directory "/doc/" link)) @@ -41,7 +44,7 @@ (shell-command (format "mv %s %s" real-file dest-path)))) (if (jao-org--pdf-p dest-path) (jao-org-links--open-pdf full-link) - (browse-url (format "file://%s" (expand-file-name dest-path)))))) + (browse-url (format "file://%s" (expand-file-name dest-path)))))) (defun jao-org-links--complete-doc (&optional arg) (let ((default-directory jao-org--sink-dir)) -- cgit v1.2.3