summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-05-20 03:23:46 +0100
committerjao <jao@gnu.org>2022-05-20 03:24:11 +0100
commitf31dd593db474575fe0edc298916586039b21aab (patch)
tree6ee5c36d109290a7aef4dcb3bb1f31f6fea393d0
parent635aba05c368fa982d2565698eb7f9f1df77714d (diff)
downloadelibs-f31dd593db474575fe0edc298916586039b21aab.tar.gz
elibs-f31dd593db474575fe0edc298916586039b21aab.tar.bz2
working better in term mode: pdfs with zathura
-rw-r--r--exwm.org7
-rw-r--r--init.org64
-rw-r--r--lib/doc/jao-org-links.el2
3 files changed, 53 insertions, 20 deletions
diff --git a/exwm.org b/exwm.org
index 29978b2..e6e5c94 100644
--- a/exwm.org
+++ b/exwm.org
@@ -330,12 +330,7 @@
(defun jao-zathura--file-info (b)
(with-current-buffer b
- (when (string-match "\\(.+\\) \\[\\(.+\\) (\\([0-9]+\\)/\\([0-9]+\\))\\]"
- (or exwm-title ""))
- (list (expand-file-name (match-string 1 exwm-title))
- (string-to-number (match-string 3 exwm-title))
- (string-to-number (match-string 4 exwm-title))
- (match-string 2 exwm-title)))))
+ (jao-zathura-file-info (or exwm-title ""))))
(defun jao-zathura-goto-page (page-no)
(jao-exwm--send-str (format "%sg" page-no)))
diff --git a/init.org b/init.org
index a6fae4a..f962db5 100644
--- a/init.org
+++ b/init.org
@@ -1868,6 +1868,42 @@
("K" . pdf-view-scroll-down-or-previous-page))))
#+end_src
+*** zathura
+ #+begin_src emacs-lisp
+ (defun jao-zathura-file-info (title)
+ (when (string-match "\\(.+\\) \\[\\(.+\\) (\\([0-9]+\\)/\\([0-9]+\\))\\]"
+ title)
+ (list (expand-file-name (match-string 1 title))
+ (string-to-number (match-string 3 title))
+ (string-to-number (match-string 4 title))
+ (match-string 2 title))))
+
+ (defun jao-zathura-goto-org (title)
+ (when-let* ((info (jao-zathura-file-info title))
+ (file (jao-org-pdf-to-org-file (car info)))
+ (page (cadr info))
+ (pageno (or (car (last info)) page)))
+ (jao-afio--goto-docs)
+ (let* ((exists (file-exists-p file))
+ (fn (file-name-nondirectory file))
+ (lnk (format "[[doc:%s::%d][Page %s]]" fn page pageno)))
+ (find-file file)
+ (unless exists (jao-org-insert-doc-skeleton))
+ (if (or (not exists) (y-or-n-p "Insert link?"))
+ (insert lnk "\n")
+ (kill-new lnk)
+ (message "Link to %s (%s) killed" file page)))))
+
+ (defun jao-zathura-open (file page)
+ (let ((id (jao-shell-string (format "xdotool search --name %s"
+ (file-name-nondirectory file)))))
+ (if (string-blank-p id)
+ (jao-shell-exec (format "zathura %s -P %s" file (or page 1)))
+ (let* ((page (if page (format " && xdotool type %dg" page) ""))
+ (cmd (format "xdotool windowactivate %s%s" id page)))
+ (jao-shell-string cmd)))))
+
+ #+end_src
*** open pdfs
#+begin_src emacs-lisp
(use-package saveplace-pdf-view
@@ -1877,25 +1913,27 @@
(setq jao-open-doc-fun 'jao-find-or-open)
- (defun jao-find-or-open (file)
- (let* ((buffs (buffer-list))
- (b (catch 'done
- (while buffs
- (when (string-equal (buffer-file-name (car buffs)) file)
- (throw 'done (car buffs)))
- (setq buffs (cdr buffs))))))
- (jao-afio--goto-docs)
- (if b (pop-to-buffer b) (find-file file))))
-
- (defun jao-open-doc (&optional file)
+ (defun jao-find-or-open (file &optional page height)
+ (if (and jao-browse-doc-use-emacs-p window-system)
+ (let* ((buffs (buffer-list))
+ (b (catch 'done
+ (while buffs
+ (when (string-equal (buffer-file-name (car buffs)) file)
+ (throw 'done (car buffs)))
+ (setq buffs (cdr buffs))))))
+ (jao-afio--goto-docs)
+ (if b (pop-to-buffer b) (find-file file)))
+ (jao-zathura-open file page)))
+
+ (defun jao-open-doc (&optional file page height)
(interactive)
(when-let (file (or file
(read-file-name "Document: "
(concat jao-org-dir "/doc/"))))
- (funcall jao-open-doc-fun file)))
+ (funcall jao-open-doc-fun file page height)))
(defun jao-afio-open-pdf (file page &optional height)
- (jao-open-doc file)
+ (jao-open-doc file page height)
(when page (jao-doc-view-goto-page page height)))
(setq jao-org-open-pdf-fun #'jao-afio-open-pdf)
diff --git a/lib/doc/jao-org-links.el b/lib/doc/jao-org-links.el
index 4704624..9102927 100644
--- a/lib/doc/jao-org-links.el
+++ b/lib/doc/jao-org-links.el
@@ -67,7 +67,7 @@
;;;###autoload
(defun jao-org-links-store-pdf-link (path page title)
- (org-store-link-props
+ (org-link-store-props
:type "doc"
:link (format "doc:%s::%d" (file-name-nondirectory path) page)
:description (format "%s (p. %d)" title page)))