From 0f8eb65fb807a125dd601cd6b3ee746e6c7b6020 Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 6 Sep 2026 15:36:38 +0100 Subject: a slew of little fixes courtesy of the byte compiler --- custom/jao-custom-pdf.el | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'custom/jao-custom-pdf.el') 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 -- cgit v1.2.3