summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-07-02 14:20:37 -0700
committerFranck Cuny <franck@fcuny.net>2022-07-02 14:39:47 -0700
commite17b0f28bd659d09e5ccebc707843b2c5dd82801 (patch)
tree0d88e55a8e0965097dc781cf938d05f52a23e610
parentfeat(notmuch): define saved searches (diff)
downloademacs.d-e17b0f28bd659d09e5ccebc707843b2c5dd82801.tar.gz
feat(org): add a capture template for tasks related to mail
By pressing "m" I can create a task related to the current opened email.

Change-Id: I63b7cc69cd6ba4fe66e9fbb526e073f75e0a7b3b
Reviewed-on: https://cl.fcuny.net/c/emacs.d/+/605
Tested-by: CI
Reviewed-by: Franck Cuny <franck@fcuny.net>
-rw-r--r--emacs/custom/my-org.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/emacs/custom/my-org.el b/emacs/custom/my-org.el
index 77d428c..55cf707 100644
--- a/emacs/custom/my-org.el
+++ b/emacs/custom/my-org.el
@@ -8,6 +8,7 @@
 (require 'org-archive)
 (require 'ox)
 (require 'ox-md)
+(require 'notmuch)
 
 (defvar my/org-directory
   (if (memq window-system '(mac ns))
@@ -96,6 +97,12 @@
          ((org-agenda-overriding-header "Not yet started")
           (org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline 'scheduled)))))))
 
+(defun my/mail-todo-format-string ()
+  "Create todo format string from mail contents."
+  (let ((from (notmuch-show-get-from))
+        (subject (notmuch-show-get-subject)))
+    (format "* TODO [#B] %s %s %%?\n:PROPERTIES:\n:CREATED: %%U\n:END:\n" from subject)))
+
 (setq org-capture-templates
 `(("t" "Todo" entry (file "inbox.org")
    "* TODO [#D] %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n")
@@ -108,6 +115,9 @@
             ":PROPERTIES:\n:CREATED: %T\n:END:\n"
             "%a\n"))
 
+  ("m" "mail" entry (file "inbox.org")
+   (function my/mail-todo-format-string))
+
   ("j" "Journal" entry
    (file+olp+datetree "journal.org")
    "* %?\n:PROPERTIES:\n:CREATED: %T\n:END:\n" :tree-type day)))