diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/doc/jao-mac.el | 24 | ||||
| -rw-r--r-- | lib/doc/jao-org-links.el | 3 | ||||
| -rw-r--r-- | lib/eos/jao-afio.el | 6 | ||||
| -rw-r--r-- | lib/net/jao-notmuch.el | 64 |
4 files changed, 67 insertions, 30 deletions
diff --git a/lib/doc/jao-mac.el b/lib/doc/jao-mac.el index cb16752..ad11ea2 100644 --- a/lib/doc/jao-mac.el +++ b/lib/doc/jao-mac.el @@ -97,7 +97,8 @@ (defun jao-skim-current-doc () "Returns a list of path and page number for the current Skim doc." - (when-let* ((p (jao-mac-run-applescript jao-skim--current-file-script))) + (when-let* ((p (jao-mac-run-applescript jao-skim--current-file-script)) + (p (and (not (string-blank-p p)) p))) (let ((ps (split-string p "::"))) (list (car ps) (string-to-number (cadr ps)))))) @@ -106,6 +107,27 @@ (when-let* ((ps (jao-skim-current-doc))) (apply 'jao-open-doc ps))) +(defvar jao-skim--current-page-text + (jao-mac-applescript-prepare + "tell application \"Skim\"" + "return the text of the current page of the front document" + "end tell")) + +(defun jao-skim-page-text () + (jao-mac-run-applescript jao-skim--current-page-text)) + +(defun jao-skim-view-page-text () + (interactive) + (when-let* ((ps (jao-skim-current-doc)) + (p (car ps)) + (n (cadr ps)) + (txt (jao-skim-page-text)) + (bn (format "*%s - %s - txt*" p n))) + (with-current-buffer (get-buffer-create bn) + (delete-region (point-min) (point-max)) + (insert txt) + (pop-to-buffer (current-buffer))))) + ;;; NetNewsWire (defvar jao-nnw--current-article-script diff --git a/lib/doc/jao-org-links.el b/lib/doc/jao-org-links.el index 5547c9b..95f2d67 100644 --- a/lib/doc/jao-org-links.el +++ b/lib/doc/jao-org-links.el @@ -18,7 +18,8 @@ (defun jao-org-links--open-pdf (link) "Open LINK using `jaor-org-open-pdf-fn'." - (cond ((string-match "\\(.*\\)::\\([0-9]*\\)\\+\\+\\([[0-9]\\.*[0-9]*\\)" link) + (cond ((string-match "\\(.*\\)::\\([0-9]*\\)\\+\\+\\([[0-9]\\.*[0-9]*\\)" + link) (let* ((path (match-string 1 link)) (page (string-to-number (match-string 2 link))) (height (string-to-number (match-string 3 link)))) diff --git a/lib/eos/jao-afio.el b/lib/eos/jao-afio.el index 162a1b7..99152b0 100644 --- a/lib/eos/jao-afio.el +++ b/lib/eos/jao-afio.el @@ -72,7 +72,7 @@ (defun jao-afio-open-pdf-session (&optional docs) (interactive) (dolist (doc (or docs (jao-doc-session))) - (when (and doc (file-exists-p doc)) + (when (and (stringp doc) (file-exists-p doc)) (if (jao-pdf-is-pdf-file doc) (jao-open-doc doc) (find-file doc)) (other-window 1))) (other-window 1)) @@ -202,8 +202,8 @@ (setq reset (or reset (not (get-register next))))) (jao-afio--current-config next) (unless (eq current next) (setq jao-afio--previous-config current)) - (when reset (jao-afio-reset)) - (run-hooks 'jao-afio-switch-hook))))) + (when reset (jao-afio-reset))) + (run-hooks 'jao-afio-switch-hook)))) (defun jao-afio-goto-main (&optional reset) (interactive "P") diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index 2471dc7..73f6420 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -1,4 +1,4 @@ -;;; jao-notmuch.el --- Extensions for notmuch -*- lexical-binding: t; -*- +;; jao-notmuch.el --- Extensions for notmuch -*- lexical-binding: t; -*- ;; Copyright (C) 2021, 2022, 2023, 2024, 2025 jao @@ -167,7 +167,7 @@ (jao-notmuch-goto-tree-buffer t))) (defun jao-notmuch--view-html () - "Open the text/html part of the current message using `notmuch-show-view-part'." + "Open the text/html part of current message using `notmuch-show-view-part'." (interactive) (save-excursion (goto-char @@ -316,6 +316,12 @@ (let ((undo (jao-notmuch--has-tag "deleted"))) (jao-notmuch-tree-tag-thread '("+deleted" "-new" "-unread") undo full))) +(defun jao-notmuch-tree-mark-all-read () + (interactive) + (when-let* ((q notmuch-tree-basic-query)) + (when (yes-or-no-p "Mark all messages as read? ") + (notmuch-tag q '("-new" "-unread"))))) + (defun jao-notmuch-tree-read-thread (full) (interactive "P") (jao-notmuch-tree-tag-thread '("-unread" "-new") nil full)) @@ -346,34 +352,21 @@ ;;; fcc -(defvar jao-notmuch-mua-reply-not-inherited - '("attachment" "sent" "new" "bigml" "jao" "trove")) - -(defun jao-notmuch-mua--fcc-dirs () - (let* ((otags (notmuch-show-get-tags)) - (trove (or (seq-some (lambda (x) (and (member x otags) x)) - '("hacking" "bills" "feeds" "jao")) - "jao")) - (tags (seq-difference otags jao-notmuch-mua-reply-not-inherited)) - (tagstr (mapconcat (lambda (s) (concat "+" s)) tags " ")) - (fcc (concat "trove/" trove " " tagstr " -new +sent +trove")) - (fcc-dirs (assoc-delete-all ".*" (copy-alist notmuch-fcc-dirs)))) - (append fcc-dirs `((".*" . ,fcc))))) +(defvar jao-notmuch-tags-not-inherited + '("attachment" "sent" "new" "trove" "flagged" "drivel")) + +(defvar jao-notmuch-sent-dir "sent") (defun jao-notmuch-mua--inherited-fcc () - (let* ((fn (notmuch-show-get-filename)) - (dest (and (string-match ".*/\\(var/mail\\|Mail\\)/\\(.+?\\)/.+" fn) - (match-string 2 fn))) - (tags (seq-difference (notmuch-show-get-tags) - '("attachment" "sent" "new" "flagged"))) + (let* ((tags (seq-difference (notmuch-show-get-tags) + jao-notmuch-tags-not-inherited)) (tagstr (mapconcat (lambda (s) (concat "+" s)) tags " ")) - (fcc (concat dest " " tagstr " -new +sent +trove")) + (fcc (concat jao-notmuch-sent-dir " " tagstr " -new +sent")) (fcc-dirs (assoc-delete-all ".*" (copy-alist notmuch-fcc-dirs)))) (append fcc-dirs `((".*" . ,fcc))))) (defun jao-notmuch-mua-new-reply (fun &rest args) - (let ((notmuch-fcc-dirs (and (not (notmuch-show-get-header :List-Id)) - (jao-notmuch-mua--inherited-fcc)))) + (let ((notmuch-fcc-dirs (jao-notmuch-mua--inherited-fcc))) (apply fun args))) (advice-add 'notmuch-mua-new-reply :around #'jao-notmuch-mua-new-reply) @@ -390,9 +383,10 @@ (seq-sort #'jao-notmuch-cmp-tags)))) (format-spec fmt `((?s . ,(mapconcat #'identity ts " ")))))) -(defun jao-notmuch-format-tree-and-subject (fmt msg) +(defun jao-notmuch-format-tree-and-subject (_fmt msg) (let ((tr (notmuch-tree-format-field "tree" " %s" msg)) - (sb (notmuch-tree-format-field "subject" " %s" msg))) + (sb (notmuch-tree-format-field "subject" " %s" msg)) + (fmt (format "%%>-%ds" (- (window-width) 60)))) (format-spec fmt `((?s . ,(concat tr sb)))))) (defun jao-notmuch-format-msg-ticks (mails-rx msg) @@ -404,4 +398,24 @@ (t " ")))) (provide 'jao-notmuch) +;;; org links +(defun jao-notmuch-id-file-name (id) + (let ((cmd (format "notmuch search --output=files id:%s" id))) + (car (split-string (shell-command-to-string cmd))))) + +(defun jao-notmuch-org-store () + (when-let* ((d (and (derived-mode-p '(notmuch-show-mode notmuch-tree-mode)) + (cons (notmuch-show-get-message-id) + (notmuch-show-get-subject))))) + (org-link-store-props :type "mail" + :link (concat "mail:" (car d)) + :description (concat "Mail: " (cdr d))))) + +(defun jao-notmuch-org-links () + (org-link-set-parameters "mail" + :follow #'notmuch-show + :store #'jao-notmuch-org-store) + (org-link-set-parameters "gnus" :store #'ignore) + (org-link-set-parameters "notmuch" :store #'ignore)) + ;;; jao-notmuch.el ends here |
