summaryrefslogtreecommitdiffhomepage
path: root/lib/doc
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-23 00:59:24 +0100
committerjao <jao@gnu.org>2022-09-23 01:04:05 +0100
commit0db03a3d92fda3c0cf368826d0fe5a224ad688d0 (patch)
tree96d62b882b4cba7bc97f4c7fc7420052f6ae1d23 /lib/doc
parent5a9447886f4930b93813a201bc7194fa183be54f (diff)
downloadelibs-0db03a3d92fda3c0cf368826d0fe5a224ad688d0.tar.gz
elibs-0db03a3d92fda3c0cf368826d0fe5a224ad688d0.tar.bz2
cleanups for pdf navigation
Diffstat (limited to 'lib/doc')
-rw-r--r--lib/doc/jao-org-links.el34
-rw-r--r--lib/doc/jao-org-notes.el13
-rw-r--r--lib/doc/jao-pdf.el16
3 files changed, 28 insertions, 35 deletions
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)
diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el
index 3f3c5ea..b7700ec 100644
--- a/lib/doc/jao-org-notes.el
+++ b/lib/doc/jao-org-notes.el
@@ -141,6 +141,19 @@
(buffer-file-name))
;;;###autoload
+(defun jao-org-notes-find-for-pdf (&optional file-name)
+ "Given a PDF file name, find its org notes counterpart."
+ (let* ((file-name (or file-name buffer-file-name))
+ (bn (file-name-base file-name))
+ (rx (format "%s\\.org$" (regexp-quote bn)))
+ (pred (lambda () (string-prefix-p jao-org-notes-dir buffer-file-name))))
+ (save-some-buffers nil pred)
+ (or (car (directory-files-recursively jao-org-notes-dir rx))
+ (let* ((d (completing-read "Notes subdir: " (jao-org-notes-cats) nil t))
+ (d (file-name-as-directory d)))
+ (expand-file-name (concat d bn ".org") jao-org-notes-dir)))))
+
+;;;###autoload
(defun jao-org-notes-grep ()
"Perform a grep search on all org notes body, via consult-ripgrep."
(interactive)
diff --git a/lib/doc/jao-pdf.el b/lib/doc/jao-pdf.el
index ad34b48..213d806 100644
--- a/lib/doc/jao-pdf.el
+++ b/lib/doc/jao-pdf.el
@@ -112,21 +112,5 @@ The result is cached as a local buffer variable."
(defun jao-pdf-zathura-org-link (title)
(jao-pdf--zathura-link (jao-pdf-zathura-file-info title)))
-(defun jao-pdf-goto-zathura-org (title &optional no-ask)
- (when-let* ((info (jao-pdf-zathura-file-info title))
- (pdf-file (car info))
- (page (cadr info))
- (file (jao-org-pdf-to-org-file 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))))))
-
(provide 'jao-pdf)
;;; jao-pdf.el ends here