Commit 087231c59d1b

Vincent Demeester <vincent@sbr.pm>
2026-01-28 16:43:04
feat(emacs): add mu4e capture template for email tasks with refile
Add "mt" capture template under email workflow that creates a TODO from an email with subject, sender, and link. After capture, automatically prompts for refile location via org-refile. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4f0788a
Changed files (1)
dots
.config
emacs
dots/.config/emacs/init.el
@@ -1921,8 +1921,26 @@ minibuffer, even without explicitly focusing it."
   (add-to-list 'org-capture-templates
 	       `("mr" "Read Later" entry
 		 (file ,org-inbox-file)
-		 "* TODO Read %:subject\nSCHEDULED:%t\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\"))\n\n%a\n\n%i" :immediate-finish t)	       
+		 "* TODO Read %:subject\nSCHEDULED:%t\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\"))\n\n%a\n\n%i" :immediate-finish t)
 	       t)
+  (add-to-list 'org-capture-templates
+	       `("mt" "Task from email" entry
+		 (file ,org-inbox-file)
+		 "* TODO %:subject :email:\n:PROPERTIES:\n:CREATED:\t%U\n:END:\n\nFrom: %:from\nEmail: %a\n\n%?"
+		 :empty-lines 1)
+	       t)
+
+  (defvar vde/org-capture-refile-templates '("mt")
+    "List of capture template keys that should trigger refile after capture.")
+
+  (defun vde/org-capture-refile-if-needed ()
+    "Refile the captured entry if the template key is in `vde/org-capture-refile-templates'."
+    (when (and (not org-note-abort)
+               (member (plist-get org-capture-plist :key) vde/org-capture-refile-templates))
+      (org-capture-goto-last-stored)
+      (call-interactively 'org-refile)))
+
+  (add-hook 'org-capture-after-finalize-hook #'vde/org-capture-refile-if-needed)
   (add-to-list 'org-capture-templates
 	       `("J" "๐Ÿ—ž Journal (antidated) entry" item
 		 (file+datetree+prompt ,org-journal-file)