From f623f601436f480ff96ff85cd7763019d96fbaa7 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 15 Oct 2021 21:14:53 +0100 Subject: capture arXiv emails for notmuch --- notmuch.org | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'notmuch.org') diff --git a/notmuch.org b/notmuch.org index 2e5b632..02afc6f 100644 --- a/notmuch.org +++ b/notmuch.org @@ -382,6 +382,7 @@ ("u" . jao-notmuch-tree-flag) ("v" . notmuch-tree-scroll-message-window) ("V" . notmuch-tree-scroll-message-window-back) + ("x" . jao-notmuch-arXiv-capture) ("<" . jao-notmuch-tree-beginning-of-buffer) (">" . jao-notmuch-tree-end-of-buffer) ("/" . notmuch-tree-view-raw-message) @@ -431,6 +432,9 @@ "Visit the notmuch message or thread with id ID." (notmuch-show id)) + (defvar jao-org-notmuch-last-subject nil) + (defun jao-org-notmuch-last-subject () jao-org-notmuch-last-subject) + (defun org-notmuch-store-link () "Store a link to a notmuch mail message." (cl-case major-mode @@ -438,8 +442,9 @@ ;; Store link to the current message (let* ((id (notmuch-show-get-message-id)) (link (concat "notmuch:" id)) - (description (format "Mail: %s" - (notmuch-show-get-subject)))) + (subj (notmuch-show-get-subject)) + (description (format "Mail: %s" subj))) + (setq jao-org-notmuch-last-subject subj) (when (y-or-n-p "Archive message? ") (if (derived-mode-p 'notmuch-show-mode) (notmuch-show-archive-message) @@ -456,13 +461,39 @@ ;; Store link to the thread on the current line (let* ((id (notmuch-search-find-thread-id)) (link (concat "notmuch:" id)) - (description (format "Mail: %s" - (notmuch-search-find-subject)))) + (subj (notmuch-search-find-subject)) + (description (format "Mail: %s" subj))) + (setq jao-org-notmuch-last-subject subj) (org-store-link-props :type "notmuch" :link link :description description))))))) #+end_src +* arXiv + #+begin_src emacs-lisp + (use-package org-capture + :config + (add-to-list 'org-capture-templates + '("X" "arXiv" entry (file "notes/physics/arxiv.org") + "* %(jao-org-notmuch-last-subject)\n %i" + :immediate-finish t) + t) + (org-capture-upgrade-templates org-capture-templates)) + + (defun jao-notmuch-arXiv-capture () + (interactive) + (save-window-excursion + (jao-notmuch-goto-message-buffer) + (save-excursion + (goto-char (point-min)) + (re-search-forward "\\[ text/html \\]") + (forward-paragraph) + (setq-local transient-mark-mode 'lambda) + (set-mark (point)) + (goto-char (point-max)) + (org-capture nil "X")))) + + #+end_src * hydras #+begin_src emacs-lisp (major-mode-hydra-define notmuch-search-mode nil -- cgit v1.2.3