summaryrefslogtreecommitdiffhomepage
path: root/custom/jao-custom-pdf.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-09-06 15:36:38 +0100
committerjao <jao@gnu.org>2026-09-06 15:36:38 +0100
commit0f8eb65fb807a125dd601cd6b3ee746e6c7b6020 (patch)
tree1d394cf0023d0d4e9df41a28c1d4376769c91d77 /custom/jao-custom-pdf.el
parent21c34f24c110e57a6c90126c87fee9cd71e85817 (diff)
downloadelibs-0f8eb65fb807a125dd601cd6b3ee746e6c7b6020.tar.gz
elibs-0f8eb65fb807a125dd601cd6b3ee746e6c7b6020.tar.bz2
a slew of little fixes courtesy of the byte compiler
Diffstat (limited to 'custom/jao-custom-pdf.el')
-rw-r--r--custom/jao-custom-pdf.el40
1 files changed, 39 insertions, 1 deletions
diff --git a/custom/jao-custom-pdf.el b/custom/jao-custom-pdf.el
index 50612bf..e82873f 100644
--- a/custom/jao-custom-pdf.el
+++ b/custom/jao-custom-pdf.el
@@ -1,6 +1,42 @@
;; -*- 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
@@ -8,9 +44,11 @@
(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-org-open-pdf-fun jao-open-doc-fun)
+ (setq jao-pdf-org-dir jao-org-dir))
;;;; doc-view
(use-package doc-view