mail: capture via org capture template
This commit is contained in:
parent
1171b61f4a
commit
bd0424f1d4
69
+mail.el
69
+mail.el
@ -71,68 +71,17 @@
|
||||
|
||||
(map! "<f2>" #'max/=mu4e)
|
||||
|
||||
(add-to-list 'org-capture-templates `("m" "email" entry (file+headline ,(expand-file-name "newgtd/actionable.org" org-directory) "Actions")
|
||||
"* NEXT Reply to [[mu4e:msgid:%:message-id][%:fromname - %:subject]] :email:\n%U\n"))
|
||||
|
||||
(defun max/mu4e-org-capture ()
|
||||
"Invoke the email capture template for msg at point"
|
||||
(interactive)
|
||||
(org-capture nil "m"))
|
||||
|
||||
(map! :after mu4e
|
||||
:map mu4e-headers-mode-map
|
||||
:vne "l" #'max/capture-msg-to-agenda)
|
||||
|
||||
(setq +org-capture-emails-file (expand-file-name "newgtd/actionable.org" org-directory))
|
||||
|
||||
;; Modified version of `+mu4e/capture-msg-to-agenda'.
|
||||
(defun max/capture-msg-to-agenda (arg)
|
||||
"Refile a message and add a entry in `+org-capture-emails-file'."
|
||||
(interactive "p")
|
||||
(let ((sec "^* Actions")
|
||||
(msg (mu4e-message-at-point)))
|
||||
(when msg
|
||||
;; put the message in the agenda
|
||||
(with-current-buffer (find-file-noselect
|
||||
(expand-file-name +org-capture-emails-file org-directory))
|
||||
(save-excursion
|
||||
;; find header section
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward sec nil t)
|
||||
(let (org-M-RET-may-split-line
|
||||
(lev (org-outline-level))
|
||||
(folded-p (invisible-p (point-at-eol)))
|
||||
(from (plist-get msg :from)))
|
||||
;; (when (consp (car from)) ; Occurs when using mu4e 1.8+.
|
||||
;; (setq from (car from)))
|
||||
(unless (keywordp (car from)) ; If using mu4e <= 1.6.
|
||||
(setq from (list :name (or (caar from) (cdar from)))))
|
||||
;; place the subheader
|
||||
(when folded-p (show-branches)) ; unfold if necessary
|
||||
(org-end-of-meta-data) ; skip property drawer
|
||||
(org-insert-heading) ; insert a todo heading
|
||||
(when (= (org-outline-level) lev) ; demote if necessary
|
||||
(org-do-demote))
|
||||
;; insert message and add deadline
|
||||
(insert (concat "NEXT Reply to "
|
||||
"[[mu4e:msgid:"
|
||||
(plist-get msg :message-id) "]["
|
||||
(truncate-string-to-width
|
||||
(plist-get from :name) 25 nil nil t)
|
||||
" - "
|
||||
(truncate-string-to-width
|
||||
(plist-get msg :subject) 40 nil nil t)
|
||||
"]] :email:\n"))
|
||||
(org-time-stamp-inactive '(16))
|
||||
|
||||
(org-update-parent-todo-statistics)
|
||||
|
||||
;; refold as necessary
|
||||
(if folded-p
|
||||
(progn
|
||||
(org-up-heading-safe)
|
||||
(hide-subtree))
|
||||
(hide-entry))))))
|
||||
;; refile the message and update
|
||||
;; (cond ((eq major-mode 'mu4e-view-mode)
|
||||
;; (mu4e-view-mark-for-refile))
|
||||
;; ((eq major-mode 'mu4e-headers-mode)
|
||||
;; (mu4e-headers-mark-for-refile)))
|
||||
(message "Added \"%s\" to the agenda"
|
||||
(truncate-string-to-width
|
||||
(plist-get msg :subject) 40 nil nil t)))))
|
||||
:vne "l" #'max/mu4e-org-capture)
|
||||
|
||||
(use-package! jl-encrypt
|
||||
:config
|
||||
|
Loading…
x
Reference in New Issue
Block a user