forked from stefanv/org-neomutt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotemacs.el
33 lines (29 loc) · 1.42 KB
/
dotemacs.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
;; Make sure org-protocol is loaded
(require org-protocol)
;; Call this function, which spawns neomutt, whenever org-mode
;; tries to open a link of the form mutt:[email protected]
;;
;; If using `maildir-utils` instead of `notmuch`, the search command becomes
;; `mu find -f l i:%s`.
(defun stefanv/mutt-open-message (message-id)
"In neomutt, open the email with the the given Message-ID"
(let*
((message-id (replace-regexp-in-string "^/*" "" message-id))
(mail-file
(replace-regexp-in-string
"\n$" "" (shell-command-to-string
(format "notmuch search --output=files id:%s" message-id))))
(mail-dir (replace-regexp-in-string "/\\(cur\\|new\\|tmp\\)/$" ""
(file-name-directory mail-file)))
(message-id-escaped (regexp-quote message-id))
(mutt-keystrokes
(format "l~i %s\n\n" (shell-quote-argument message-id-escaped)))
(mutt-command (list "neomutt" "-R" "-f" mail-dir
"-e" (format "push '%s'" mutt-keystrokes))))
(message "Launching neomutt for message %s" message-id)
(call-process "setsid" nil nil nil
"-f" "gnome-terminal" "--window" "--"
"neomutt" "-R" "-f" mail-dir
"-e" (format "push '%s'" mutt-keystrokes))))
;; Hook up `mutt:...` style URLs
(org-add-link-type "message" 'stefanv/mutt-open-message)