blob: e82873fd53b37f55ac300ca536378d38083ebc04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
;; -*- lexical-binding: t -*-
;;;; open pdfs
(defun jao-find-or-open (file &optional page height)
(cond ((and jao-pdf-open-in-emacs 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))
(when page (jao-doc-view-goto-page page height))))
(jao-river-enabled (jao-river-open-with-zathura file page))
(jao-sway-enabled (jao-sway-open-with-zathura file page))
((eq system-type 'darwin) (jao-mac-open-in-skim file page))
(t (jao-zathura-open file page))))
(defun jao-open-with-zathura ()
(interactive)
(jao-when-linux
(when-let* ((f buffer-file-name))
(let ((p (jao-doc-view-current-page)))
(cond (jao-river-enabled (jao-river-open-with-zathura f p))
(jao-sway-enabled (jao-sway-open-with-zathura f p))
(t (jao-zathura-open f p)))))))
(defun jao-zathura-open (file page)
(jao-when-linux
(let ((id (jao-x11-search-window (jao-pdf-zathura-title-rx file))))
(if (string-blank-p id)
(progn
(when jao-xmonad-enabled (jao-x11-goto-ws 2))
(jao-shell-exec (jao-pdf-zathura-open-cmd file page)))
(let* ((page (if page (format " && xdotool type %dg" page) ""))
(cmd (format "xdotool windowactivate %s%s" id page)))
(jao-shell-exec cmd t))))))
(use-package saveplace-pdf-view
:ensure t
:demand t
:after doc-view)
(use-package jao-pdf
:demand t
:after jao-custom-org
:config
(setq jao-open-doc-fun 'jao-find-or-open)
(setq jao-org-open-pdf-fun jao-open-doc-fun)
(setq jao-pdf-org-dir jao-org-dir))
;;;; doc-view
(use-package doc-view
:init
(setq doc-view-cache-directory "~/.emacs.d/cache/docview"
doc-view-resolution 110
doc-view-continuous t
doc-view-conversion-refresh-interval 1
doc-view-mupdf-use-svg t)
(defalias 'jao-doc-view-externally
(jao-d-l 'jao-mac-open-in-skim 'jao-open-with-zathura))
:hook ((doc-view-mode . jao-doc-session-mark))
:bind (:map doc-view-mode-map
("j" . doc-view-next-line-or-next-page)
("J" . doc-view-search-next-match)
("k" . doc-view-previous-line-or-previous-page)
("K" . doc-view-search-previous-match)
("z" . jao-doc-view-externally)))
(use-package jao-doc-session :demand t)
(use-package jao-doc-view
:demand t
:bind (:map doc-view-mode-map
("b" . jao-doc-view-back)
("B" . jao-doc-view-forward)
("S" . jao-doc-session-save)
("u" . jao-doc-view-visit-url)))
;;;; transient
(defun jao-org-pdf-goto-org-linking ()
(interactive)
(jao-org-pdf-goto-org 4))
(jao-transient-major-mode doc-view
["Notes"
("o" "notes file" jao-org-pdf-goto-org)
("O" "notes file, linking" jao-org-pdf-goto-org-linking)]
["Navigation"
("b" "back jump" jao-doc-view-back)
("B" "forward jump" jao-doc-view-back)
("u" "visit URL" jao-doc-view-visit-url)]
["Slices"
("cb" "bounding box" doc-view-set-slice-from-bounding-box)
("cm" "using mouse" doc-view-set-slice-using-mouse)]
["Session"
("s" "load session" jao-afio-open-pdf-session)
("S" "save session" jao-doc-session-save)
("d" "visit cache directory" doc-view-dired-cache)]
["External viewers"
("z" "open with zathura" jao-open-with-zathura :if jao-is-linux)
("z" "open with skim" jao-mac-open-in-skim :if jao-is-darwin)])
(with-eval-after-load "pdf-view"
(jao-transient-major-mode pdf-view
["Notes"
("o" "notes file" jao-org-pdf-goto-org)
("O" "notes file, linking" jao-org-pdf-goto-org-linking)]
["Navigation"
("b" "back jump" pdf-history-backward)
("f" "forward jump" pdf-history-forward)]
["Session"
("s" "load session" jao-afio-open-pdf-session)
("S" "save session" jao-doc-session-save)]
["External viewers"
("z" "open with zathura" jao-open-with-zathura)]))
;; (transient-get-suffix 'jao-transient-pdf-view '(0 -1))
(provide 'jao-custom-pdf)
|