diff options
Diffstat (limited to 'lisp/+pdf-tools.el')
-rw-r--r-- | lisp/+pdf-tools.el | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lisp/+pdf-tools.el b/lisp/+pdf-tools.el new file mode 100644 index 0000000..9b15b27 --- /dev/null +++ b/lisp/+pdf-tools.el | |||
@@ -0,0 +1,38 @@ | |||
1 | ;;; +pdf-tools.el --- Extras for the excellent pdf-tools' -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;;; Code: | ||
6 | |||
7 | ;; XXX: The way I'm dispatching browsers here is /very/ down-and-dirty. It | ||
8 | ;; needs to be much improved. | ||
9 | |||
10 | (defun +pdf-view-open-all-pagelinks (&optional browse-url-func) | ||
11 | "Open all the links on this page of a PDF. | ||
12 | BROWSE-URL-FUNC overrides the default `browse-url'." | ||
13 | (interactive) | ||
14 | (let ((links (pdf-info-pagelinks (pdf-view-current-page))) | ||
15 | (browse-url-func (or browse-url-func #'browse-url)) | ||
16 | (seen)) | ||
17 | (dolist (link links) | ||
18 | (when-let* ((uri (alist-get 'uri link)) | ||
19 | (_ (not (member uri seen)))) | ||
20 | (push uri seen) | ||
21 | (funcall browse-url-func uri))))) | ||
22 | |||
23 | (defun +pdf-view-open-links-in-chrome () | ||
24 | "Open all links on this PDF page in Chrome. | ||
25 | See also `+pdf-view-open-all-pagelinks'." | ||
26 | (interactive) | ||
27 | (+pdf-view-open-all-pagelinks #'browse-url-chrome)) | ||
28 | |||
29 | (defun +pdf-view-position (&optional spacer) | ||
30 | "Return the page we're on for the modeline." | ||
31 | (when (derived-mode-p 'pdf-view-mode) | ||
32 | (format "%sp.%s/%s" | ||
33 | (or spacer (bound-and-true-p +modeline-default-spacer) " ") | ||
34 | (pdf-view-current-page) | ||
35 | (pdf-info-number-of-pages)))) | ||
36 | |||
37 | (provide '+pdf-tools) | ||
38 | ;;; +pdf-tools.el ends here | ||