[emacs] Add my customised version of +mu4e/capture-msg-to-agenda
This commit is contained in:
parent
62d61c678b
commit
7faa1645da
|
@ -65,6 +65,7 @@
|
|||
org-refile-use-outline-path 'file
|
||||
org-return-follows-link t
|
||||
org-scheduled-delay-days 0
|
||||
+org-capture-emails-file "Todo.org"
|
||||
org-show-notification-handler "notify-send"
|
||||
org-startup-folded t
|
||||
org-tag-faces (quote (("next" . "red") ("waiting" . "blue")))
|
||||
|
@ -354,6 +355,63 @@
|
|||
(format-time-string "%Y-%m-%d.md"
|
||||
(time-subtract (current-time) (days-to-time 1))) "~/WirZwei/Zettelkasten/journals")))
|
||||
|
||||
|
||||
(defun +mu4e/capture-msg-to-agenda (arg)
|
||||
"Refile a message and add a entry in `+org-capture-emails-file' with a
|
||||
deadline. Default deadline is today. With one prefix, deadline
|
||||
is tomorrow. With two prefixes, select the deadline."
|
||||
(interactive "p")
|
||||
(let ((sec "^* Email")
|
||||
(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-max))
|
||||
(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))
|
||||
(setq from (car from)))
|
||||
(org-end-of-meta-data) ; skip property drawer
|
||||
(org-insert-todo-heading 1) ; insert a todo heading
|
||||
;; insert message and add deadline
|
||||
(insert (concat "Email beantworten: "
|
||||
"[[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:"))
|
||||
(org-deadline nil
|
||||
(cond ((= arg 1) (format-time-string "%Y-%m-%d"))
|
||||
((= arg 4) "+1d")))
|
||||
|
||||
(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 "Refiled \"%s\" and added to the agenda for %s"
|
||||
(truncate-string-to-width
|
||||
(plist-get msg :subject) 40 nil nil t)
|
||||
(cond ((= arg 1) "today")
|
||||
((= arg 4) "tomorrow")
|
||||
(t "later"))))))
|
||||
|
||||
(setq org-agenda-category-icon-alist
|
||||
'(("Todo" "~/.icons/emacs/todo-16x16.png" nil nil :ascent center)
|
||||
("Personal" "~/.icons/emacs/person-16x16.png" nil nil :ascent center)
|
||||
|
|
Loading…
Reference in New Issue