In the following I will put forward my philosophy on handling emails and then show how this is realised in emacs using mu4e and org-mode.

I couple of years ago I read an article by the economist Tim Harford which hugely influenced the way I handle my emails. The ideas in the article are not unique but they really struck a chord with me. My email philosophy can be distilled down to one key concept:

your inbox is not a todo list

Like many people I used to keep emails in my inbox as a way of reminding me of something I needed to do, but the fact is that an inbox is a rubbish todo list.

I also had folders for putting emails in and I would occasionally have a painful cleanout of my towering inbox, agonising over which folder to put an email in, or whether I should create a new folder for it. No more! As long as your email programme has a good search, then it is quicker to search than to use a filing system.

Now when I check my emails, I do one of the following

delete if it is rubbish

read and delete if it is not something I’ll need to revisit

read and archive if it is something I might need to look up again

reply and archive if it is something that will take less than a couple of minutes to reply to and I have the time

add to todo list and archive if it is something that requires an action or just needs a longer reply than I have time to write

To use this system effectively, all you really need is: (i) an email client with a good search function so you can archive all mail in the same folder and not worry about filing it neatly, and (ii) a good system for adding tasks from your emails to a todo list.

The mu4e email client in emacs, combined with org-mode for todo organisation is the perfect way to do both of these things. There is very good documentation on how to set up mu4e on the project web page, including configuring it to work well with gmail, so I won’t go over that here. What I will say is that mu4e is built on mu, a powerful email indexer so it has all of your search needs covered.

Apart from searching, mu4e integrates very well with org-mode to make it seamless to generate todo items from emails. To set this up, add the following to your emacs config file

;;store org-mode links to messages(require 'org-mu4e);;store link to message if in header view, not to header query(setq org-mu4e-link-query-in-headers-mode nil)

This looks like the version we had before, but the extra %a adds a link to the file you are visiting when you invoke the capture template.

The beauty of this is that hitting C-c c t now generates a todo item that contains a link to the email you are currently viewing. So you have zero friction in creating a todo item to e.g. reply to an email by a certain deadline, and you can happily archive that email knowing that clicking the link in the todo item will take you directly back to it.

I moved from thunderbird to mu4e a couple of months ago and really haven’t looked back. The things I missed at first were some of the extensions I was using to: create email templates; remind me about attachments; and add a delay to outgoing email so that I could have an “undo send” functionality. Happily I’ve found solutions to all of these in mu4e and I’ll be covering them in future posts.

Use dired-jump, which is bound to C-x C-j by default to show the current file in a dired buffer. The command is part of dired-x which is built in to emacs, but you may need to add the following to your emacs config file to activate it.

In this post we’ll build on the simple todo list that we put together previously and add schedules and deadlines to our tasks to build a powerful agenda.

When adding a task (with C-c c t) you can add a scheduled date to it with C-c C-s or a deadline date with C-c C-d, or both. These will pop up a calendar which you can navigate using shift and the arrow keys.

I prefer to schedule all new tasks to today’s date as a default, so I update the org-capture-templates variable to

You can edit the date by putting the cursor in it and using shift + arrow keys.

Now instead of using C-c a t to view your list of tasks, we will use C-c a n to display a list of your scheduled tasks and then any unscheduled tasks below it.

I have several configuration options that I recommend. Add the following to your emacs config file if you like the look of them:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org-mode agenda options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;open agenda in current window(setq org-agenda-window-setup (quote current-window));;warn me of any deadlines in next 7 days(setq org-deadline-warning-days 7);;show me tasks scheduled or due in next fortnight(setq org-agenda-span (quote fortnight));;don't show tasks as scheduled if they are already shown as a deadline(setq org-agenda-skip-scheduled-if-deadline-is-shown t);;don't give awarning colour to tasks with impending deadlines;;if they are scheduled to be done(setq org-agenda-skip-deadline-prewarning-if-scheduled (quote pre-scheduled));;don't show tasks that are scheduled or have deadlines in the;;normal todo list(setq org-agenda-todo-ignore-deadlines (quote all))(setq org-agenda-todo-ignore-scheduled (quote all));;sort tasks in order of when they are due and then by priority(setq org-agenda-sorting-strategy
(quote
((agenda deadline-up priority-down)(todo priority-down category-keep)(tags priority-down category-keep)(search category-keep))))

With these options we get a really useful view of our tasks when using C-c a n. For example, here is a todo.org file with a mixture of tasks with and without schedules and deadlines

* Tasks** TODO[#A] do this todaySCHEDULED:<2015-12-08 Tue>** TODO[#A] do this tomorrowSCHEDULED:<2015-12-09 Wed>** TODO[#A] this task is not scheduled** TODO[#B] scheduled for today, priority BSCHEDULED:<2015-12-08 Tue>** TODO[#A] scheduled today and deadline in 2 daysDEADLINE:<2015-12-10 Thu>SCHEDULED:<2015-12-08 Tue>** TODO[#A] deadline in 2 days and not scheduledDEADLINE:<2015-12-10 Thu>** TODO[#A] scheduled for mondaySCHEDULED:<2015-12-14 Mon>** TODO[#C] do this today if I get timeSCHEDULED:<2015-12-08 Tue>** TODO[#B] neither is this one** TODO[#C] or this one** TODO[#A] deadline in 10 days and not scheduledDEADLINE:<2015-12-18 Fri>

Any time you find yourself doing a repetitive task in emacs, you should stop and think about whether you could be using a macro to automate it. To use a macro you start a recording and do whatever edits or other commands you need for your task, then stop the macro and execute it to repeat the task as many times as you like. There is a great introduction and overview of macros at emacs-fu.

I wanted to pick out from that article a useful feature of macros that I have neglected until recently. Normally a macro is saved until you record a new one, in which case it is overwritten. However it is possible to give your macro and name and then save it for future use.

At the moment I am rewriting some LaTeX notes into org mode to use in lecture slides. This involves several repetitive tasks, like converting a section heading like this

\subsection{Object on vertical spring}

into this

** Object on vertical spring

The trick to making a good macro is to make it as general as possible, like searching to move to a character instead of just moving the cursor. In this case I did the following:

Start with the cursor somewhere on the line containing the subsection and hit C-x C-( to start the macro recording

C-a to go to the start of the line

C-SPC to set the mark

C-s { to search forward to the “{” character

RET to exit the search

C-d to delete the region

Type “** ” to add my org style heading

C-e to move to the end of the line

BACKSPACE to get rid of the last “}”

C-x ) to end the recording

Now I can replay my macro with C-x e but I know I’ll need this again many times in the future so I use M-x name-last-kbd-macro and enter a name for the macro (e.g. bjm/sec-to-star). Now I go to my emacs config file and add the following