summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
-rw-r--r--lib/eos/jao-wayland.el4
-rw-r--r--lib/net/jao-notmuch.el84
5 files changed, 30 insertions, 121 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
diff --git a/lib/eos/jao-wayland.el b/lib/eos/jao-wayland.el
index 9f503f8..5a457a4 100644
--- a/lib/eos/jao-wayland.el
+++ b/lib/eos/jao-wayland.el
@@ -66,7 +66,7 @@
(defun jao-river-zathura-to-org ()
(let ((title (jao-river-get-focused-title)))
(jao-river-to-ws 1)
- (jao-pdf-goto-zathura-org title t)))
+ (jao-org-open-from-zathura title t)))
(defun jao-river-zathura-kill-link ()
(when-let* ((title (jao-river-get-focused-title))
@@ -129,7 +129,7 @@
(and (string-match "\"\\(.+\\)\"" tl) (match-string 1 tl))))
(defun jao-sway-zathura-org ()
- (jao-pdf-goto-zathura-org (jao-sway-get-active-title) t))
+ (jao-org-open-from-zathura (jao-sway-get-active-title) t))
(defun jao-sway-open-with-zathura (file page)
(let* ((n (file-name-nondirectory file))
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index d7e27b6..6dcb73e 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -270,90 +270,6 @@
(concat " " subject)))
-;;; outline mode for tree view
-
-(defun jao-notmuch-tree--msg-prefix (msg)
- (insert (propertize (if (plist-get msg :first) "> " " ") 'display " ")))
-
-(defun jao-notmuch-tree--mode-setup ()
- (setq-local outline-regexp "^> \\|^En")
- (outline-minor-mode t))
-
-(defun jao-notmuch-tree-hide-others (&optional and-show)
- (interactive)
- (outline-hide-body)
- (outline-show-entry)
- (when and-show (notmuch-tree-show-message nil)))
-
-(defsubst jao-notmuch-tree--message-open ()
- (and (buffer-live-p notmuch-tree-message-buffer)
- (get-buffer-window notmuch-tree-message-buffer)))
-
-(defsubst jao-notmuch--get-prop (prop &optional props)
- (or (and props (plist-get props prop))
- (notmuch-tree-get-prop prop)
- (notmuch-show-get-prop prop)))
-
-(defun jao-notmuch--looking-at-match-p ()
- (and (jao-notmuch--get-prop :match)
- (equal (jao-notmuch--get-prop :orig-tags)
- (jao-notmuch--get-prop :tags))))
-
-(defun jao-notmuch-tree--next (prev thread no-exit &optional ignore-new)
- (let ((line-move-ignore-invisible nil))
- (cond ((and (not ignore-new)
- (jao-notmuch--looking-at-match-p)
- (not (jao-notmuch-tree--message-open))))
- (thread
- (notmuch-tree-next-thread prev)
- (unless (or (not (notmuch-tree-get-message-properties))
- (jao-notmuch--looking-at-match-p))
- (notmuch-tree-matching-message prev (not no-exit))))
- (t (notmuch-tree-matching-message prev (not no-exit)))))
- (when (notmuch-tree-get-message-id)
- (jao-notmuch-tree-hide-others t))
- (when prev (forward-char 2)))
-
-(defvar jao-notmuch-tree--prefix-map
- (let ((m (make-keymap "Thread operations")))
- (define-key m (kbd "TAB") #'outline-cycle)
- (define-key m (kbd "t") #'outline-toggle-children)
- (define-key m (kbd "s") #'outline-show-entry)
- (define-key m (kbd "S") #'outline-show-all)
- (define-key m (kbd "h") #'outline-hide-entry)
- (define-key m (kbd "H") #'outline-hide-body)
- (define-key m (kbd "o") #'jao-notmuch-tree-hide-others)
- (define-key m (kbd "n") #'outline-hide-other)
- m))
-
-(defun jao-notmuch-tree-outline-setup (&optional prefix)
- (define-key notmuch-tree-mode-map (kbd (or prefix "T"))
- jao-notmuch-tree--prefix-map)
- (define-key notmuch-tree-mode-map (kbd "TAB") #'outline-cycle)
- (define-key notmuch-tree-mode-map (kbd "M-TAB") #'outline-cycle-buffer)
- (add-hook 'notmuch-tree-mode-hook #'jao-notmuch-tree--mode-setup)
- (advice-add 'notmuch-tree-insert-msg :before #'jao-notmuch-tree--msg-prefix))
-
-(defun jao-notmuch-tree-next (thread &optional no-exit)
- "Next message or thread in forest, taking care of thread visibility."
- (interactive "P")
- (jao-notmuch-tree--next nil thread no-exit))
-
-(defun jao-notmuch-tree-next-thread (&optional exit)
- "Next thread in forest, taking care of thread visibility."
- (interactive "P")
- (jao-notmuch-tree--next nil t exit))
-
-(defun jao-notmuch-tree-previous (thread)
- "Previous message or thread in forest, taking care of thread visibility."
- (interactive "P")
- (jao-notmuch-tree--next t thread t))
-
-(defun jao-notmuch-tree-previous-thread (&optional exit)
- "Previous thread in forest, taking care of thread visibility."
- (interactive "P")
- (jao-notmuch-tree--next t t exit))
-
;;; tree setup overall function
(defun jao-notmuch-tree--sentinel (proc)