From fedeab4ab8a7a267072421535f852b350f42fb9d Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 21 Sep 2022 22:24:45 +0100 Subject: more clever open with zathura in doc/pdf-view --- init.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/init.el b/init.el index 30c3457..505af28 100644 --- a/init.el +++ b/init.el @@ -257,11 +257,11 @@ ((mailcap-user-mime-data `((jao-icalendar-import-buffer "application/ics") ("emacsclient -e '(jao-icalendar-import-invite \"%s\")'" "application/ics") - (pdf-view-mode "application/pdf" (display-graphic-p)) + (doc-view-mode "application/pdf" (display-graphic-p)) ("zathura \"%s\"" "application/pdf") - (image-mode "image/*" (display-graphic-p)) + ;; (image-mode "image/*" (display-graphic-p)) ("firefox %s && riverctl set-focused-tags 2" "text/html" jao-river-enabled) - ("swayimg \"%s\"" "image/*": jao-sway-enabled) + ("swayimg \"%s\"" "image/*" jao-sway-enabled) ("imv-wayland \"%s\"" "image/*" jao-wayland-enabled) ("imv-x11 \"%s\"" "image/*"))))) @@ -1504,7 +1504,6 @@ ;;;; pdf-tools (use-package pdf-tools - :disabled t :ensure t :demand t :init @@ -1611,10 +1610,13 @@ (interactive) (jao-org-pdf-goto-org 4)) -(defun jao-doc-view-open-with-zathura () +(defun jao-open-with-zathura () (interactive) - (when buffer-file-name - (jao-zathura-open buffer-file-name (doc-view-current-page)))) + (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)))))) (jao-transient-major-mode doc-view ["Notes" @@ -1632,7 +1634,7 @@ ("S" "save session" jao-doc-session-save) ("d" "visit cache directory" doc-view-dired-cache)] ["External viewers" - ("z" "open with zathura" jao-doc-view-open-with-zathura)]) + ("z" "open with zathura" jao-open-with-zathura)]) (with-eval-after-load "pdf-view" (jao-transient-major-mode pdf-view @@ -1644,7 +1646,9 @@ ("f" "forward jump" pdf-history-forward)] ["Session" ("s" "load session" jao-afio-open-pdf-session) - ("S" "save session" jao-doc-session-save)])) + ("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)) -- cgit v1.2.3