summaryrefslogtreecommitdiffhomepage
path: root/lib/doc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/doc')
-rw-r--r--lib/doc/jao-org-links.el11
-rw-r--r--lib/doc/jao-pdf.el20
2 files changed, 22 insertions, 9 deletions
diff --git a/lib/doc/jao-org-links.el b/lib/doc/jao-org-links.el
index dd8f2bb..acfe176 100644
--- a/lib/doc/jao-org-links.el
+++ b/lib/doc/jao-org-links.el
@@ -82,7 +82,7 @@
(file-name-directory jao-org-notes-dir)))
;;;###autoload
-(defun jao-org-pdf-to-org-file (&optional file-name)
+(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))))
@@ -90,9 +90,12 @@
(lambda ()
(string-prefix-p jao-org-notes-dir buffer-file-name)))
(or (car (directory-files-recursively jao-org-notes-dir rx))
- (let* ((dirs (jao-org-notes-cats))
- (dir (completing-read "Notes subdir: " dirs nil t)))
- (expand-file-name (concat dir "/" bn ".org") jao-org-notes-dir)))))
+ (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)))))
;;;###autoload
(defun jao-org-insert-doc-skeleton (&optional title)
diff --git a/lib/doc/jao-pdf.el b/lib/doc/jao-pdf.el
index 6a44693..ad34b48 100644
--- a/lib/doc/jao-pdf.el
+++ b/lib/doc/jao-pdf.el
@@ -91,6 +91,7 @@ The result is cached as a local buffer variable."
(let ((page (if page (format "-P %s" page) "")))
(format "zathura %s %s %s" file page (or suffix ""))))
+;; e.g. "~/org/doc/write-yourself-a-scheme-in-48-hours.pdf [96 (96/138)]"
(defun jao-pdf-zathura-file-info (title)
(when (string-match "\\(.+\\) \\[\\(.+\\) (\\([0-9]+\\)/\\([0-9]+\\))\\]"
title)
@@ -99,19 +100,28 @@ The result is cached as a local buffer variable."
(string-to-number (match-string 4 title))
(match-string 2 title))))
+(defun jao-pdf--zathura-link (info)
+ (when-let* ((file (car info))
+ (page (cadr info))
+ (no (or (car (last info)) page))
+ (fn (file-name-nondirectory file))
+ (lnk (format "doc:%s::%s" fn page))
+ (desc (format "%s (p. %s)" (jao-pdf-section-title page file) no)))
+ (org-make-link-string lnk desc)))
+
+(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))
- (file (jao-org-pdf-to-org-file pdf-file))
(page (cadr info))
- (pageno (or (car (last info)) page)))
+ (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* ((fn (file-name-nondirectory pdf-file))
- (desc (jao-pdf-section-title page pdf-file))
- (lnk (format "[[doc:%s::%d][%s (p. %s)]]" fn page desc pageno)))
+ (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")