summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-02-03 04:04:16 +0000
committerjao <jao@gnu.org>2021-02-03 04:04:16 +0000
commit50d1776b7f98d5833b4e3f9e65dce8e9d452c05e (patch)
tree2ebc00c14c4a02c1bdc736d7e6f607189f95010c
parent535a578fd12211e6ec2293de96bb6877c4cf51c1 (diff)
downloadelibs-50d1776b7f98d5833b4e3f9e65dce8e9d452c05e.tar.gz
elibs-50d1776b7f98d5833b4e3f9e65dce8e9d452c05e.tar.bz2
jao-org-links: move to afio ws on opening doc: link
-rw-r--r--exwm.org2
-rw-r--r--init.org6
-rw-r--r--lib/org/jao-org-links.el15
3 files changed, 16 insertions, 7 deletions
diff --git a/exwm.org b/exwm.org
index 3450a69..5cc5095 100644
--- a/exwm.org
+++ b/exwm.org
@@ -358,7 +358,7 @@
(defun jao-exwm-pdf-disable-zathura ()
(interactive)
(remove-hook 'kill-emacs-query-functions #'jao-exwm-pdf-zathura-close-all)
- (setq jao-org-open-pdf-fun nil)
+ (setq jao-org-open-pdf-fun #'jao-afio-open-pdf)
(setq jao-org-links-pdf-store-fun nil)
(setq jao-open-doc-fun #'jao-find-or-open))
diff --git a/init.org b/init.org
index 252487c..4efb652 100644
--- a/init.org
+++ b/init.org
@@ -1652,6 +1652,12 @@
(dolist (doc (jao-doc-view-session))
(when (and (file-exists-p doc) (y-or-n-p (format "Open %s? " doc)))
(jao-find-or-open doc))))
+
+ (defun jao-afio-open-pdf (file page &optional height)
+ (jao-open-doc file)
+ (when page (jao-org--pdf-go page height)))
+
+ (setq jao-org-open-pdf-fun #'jao-afio-open-pdf)
#+END_SRC
* Email
*** message mode
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))