remember Mutt's mail in Org-mode and jump back to themAs already anticipated, I've been implementing my own Getting Things Done work flow. This post documents one of its main bricks: the integration between Mutt and Org-mode. As a geek, my main incoming stream of TODO items and information in general is email. As emails hit my INBOX, I either deal with them immediately (reply, archive, delete) or I need to store them elsewhere, possibly adding extra information such as a deadline, a personal note, the associated next action, the context in which it is actionable, etc. This need of adding extra information is what defeats the usage of my mail client (Mutt) as a list manager (in the GTD sense), and that's where I plugged Org-mode in. My main goals are:
In fact, both would be straightforward to achieve if I were using some Emacs-based mail client such as Gnus, but I resist the Emacs operating system syndrome, and therefore I insist in using my beloved Mutt. Let's see how the two parts of the interaction between Mutt and Org-mode work. (1) Mutt → Org-mode (there ...)The interaction from Mutt to Org-mode happens via org-protocol. Using it external applications can feed content to Org-mode note templates, which are then interactively edited (via emacsclient), and finally filed away. The Mutt glue macro from my
The remember-mail script is trivial: it parses the fed mail from STDIN (using a couple of legacy Perl modules) and then invokes org-protocol. The relevant configuration from my
The result is that when you hit (2) Org-mode → Mutt (... and back again)Going back means that clicking on a "mail" hyperlink within an Org-mode note should bring up a Mutt instance showing the original message, in its context (e.g. its own mailbox). Achieving that consists of 2 separate steps:
For the first part I use maildir-utils
(AKA mu): a
Xapian-based mail indexing tool, which nicely integrates with Mutt;
check out my
previous blog post on the subject for a sample setup. Using mu,
Note: I'm relying upon maildir-utils version 0.6 or greater, for all presented scripts. For the second part I use the mutt-open script which fires upon a Mutt instance on the maildir containing a specific message, and then "hits" the appropriate keys to open the message and shutdown the sidebar (if desired). It is a nicely reusable script, which I've being using elsewhere too. The needed glue on the emacs side is just a function to invoke
Voilà! DownloadSummary of scripts and configuration snippets discussed above:
Update: fix mutt-open to work with maildir-utils, version 7 or above (22/01/2011, at org-camp) |

thanks for your post [0]. Since I was reluctant to leave mutt (running in an M-x ansi-term anyway) for a pure elisp based solution (they all seemed overly complex to set up and unbearably slow with my HUGE imaps mailboxes) it helped me a great deal to get org integration working.
I left out the mu part entirely though and since I use sth. like (with-current-buffer "inbox" (term-send-raw-string (concat "/~i" message "\n\n")))) in my .emacs no shell script is needed.[1]
thanks again,
take care,
x
[0] http://upsilon.cc/~zack/blog/posts/2010/02/integratingMuttwith_Org-mode/ [1] this has the obvious disadvantage that I need to have the right mailbox open, but I am fine with that so far.
Hello. Thank you so much for this post, I loved it! I am an old time mutt user, and I am starting to use org-mode, and this integration is awesome.
I just wanted to point out that it seems the letters for the mu command has changed in the 0.7 version. To get the path from a message id it's not mu find -f pMmessage-id, but now mu find -p l i:message-id
Many thanks for this, it really has improved my workflow! I currently run Mutt in Multi-term within Emacs and so just had to change the exec to drop the "-t" flag.
I really can't believe I never spent the time before configuring remember and templates. It really is quite a beautiful thing, and more so now with Mutt.
Thanks again.
Hi
I ran into a problem with your mutt-open script when I tried to find a message whose message ID included "+" characters. I discovered that unfortunately Mutt interpreted those as regex characters.
To try and escape the msgid string I inserted the substitutions below:
And yes it really took all those backslashes to make it all the way into the mutt expression. There could easily be a better way to escape the string, I didn't even know bash could do string substitutions until a few minutes ago.