From 0db03a3d92fda3c0cf368826d0fe5a224ad688d0 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 23 Sep 2022 00:59:24 +0100 Subject: cleanups for pdf navigation --- lib/doc/jao-org-links.el | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'lib/doc/jao-org-links.el') diff --git a/lib/doc/jao-org-links.el b/lib/doc/jao-org-links.el index acfe176..8b5c42e 100644 --- a/lib/doc/jao-org-links.el +++ b/lib/doc/jao-org-links.el @@ -77,25 +77,21 @@ (insert (format "[[doc:%s][%s]]" (jao-pdf-title-to-file-name title) title))) ;;;###autoload -(defun jao-org-org-to-pdf-file () - (expand-file-name (concat "doc/" (file-name-base buffer-file-name) ".pdf") - (file-name-directory jao-org-notes-dir))) - -;;;###autoload -(defun jao-org-pdf-to-org-file (&optional file-name no-ask) - (let* ((file-name (or file-name buffer-file-name)) - (bn (file-name-base file-name)) - (rx (format "%s\\.org$" (regexp-quote bn)))) - (save-some-buffers nil - (lambda () - (string-prefix-p jao-org-notes-dir buffer-file-name))) - (or (car (directory-files-recursively jao-org-notes-dir rx)) - (let ((d (if no-ask - "" - (concat (completing-read "Notes subdir: " - (jao-org-notes-cats) nil t) - "/")))) - (expand-file-name (concat dir bn ".org") jao-org-notes-dir))))) +(defun jao-org-open-from-zathura (title &optional no-ask) + (when-let* ((info (jao-pdf-zathura-file-info title)) + (pdf-file (car info)) + (page (cadr info)) + (file (jao-org-notes-find-for-pdf pdf-file))) + (ignore-errors (jao-afio-goto-docs)) + (let ((exists (file-exists-p file))) + (find-file file) + (unless exists (jao-org-insert-doc-skeleton)) + (let ((lnk (jao-pdf--zathura-link info))) + (jao-doc-session-mark) + (if (or (not exists) (and (not no-ask) (y-or-n-p "Insert link?"))) + (insert lnk "\n") + (kill-new lnk) + (message "Link to %s (%s) killed" file page)))))) ;;;###autoload (defun jao-org-insert-doc-skeleton (&optional title) -- cgit v1.2.3