May 4, 2012

Emacs Org-mode Agendas

I love Emacs org-mode. After discovering that the adgenda views, I love it even more!

In the tradition of GTD, I maintain a file where I keep a list of anything and everything I can think of that I need to get done and/or maybe want to do someday. This might seem a little crazy if you've never heard of GTD before, but I find that it is very liberating to get everything out of my brain and down on paper (..err, into a text file). It frees up my brain to do more important things...like daydream about the Hokies winning the Orange Bowl this year.

I try to write down pretty much any thought that pops in my brain; things like "Take out the trash on Wed", "Someday go watch the British Open", and "Implement search in blog". The file has grown pretty large over the past few years. Emacs org-mode makes it really easy to filter this list so that I can see exactly what I need/want to work on every day. It's called the org-mode adgenda and the Emacs command `C-c a` brings up a nice menu of options

Press key for an agenda command:        <   Buffer,subtree/region restriction
--------------------------------        >   Remove restriction
a   Agenda for current week or day      e   Export agenda views
t   List of all TODO entries            T   Entries with special TODO kwd
m   Match a TAGS query                  M   Like m, but only TODO entries
L   Timeline for current buffer         #   List stuck projects (!=configure)
s   Search for keywords                 C   Configure custom agenda commands
/   Multi-occur

I use tags to organize all my todo items. So, each day, I want to see all todo items that are not tagged with "someday" or "repeating". And I also only want to see tasks that haven't been compelted. By using C-c a and then choosing m I can write a search query like this:

 C-a m {.*}-someday-repeating/-DONE

This works great, but it's not very easy to remember that whole command, so this morning I wondered if I could create a custom org-mode adgenda command.

Thankfully, Emacs' documentation system is also one of Emacs' killer features and so figuring out how to accomplish this customization was dead simple. First, I figured out which command was linked to C-c a using the describe-key (C-h k) trick. That showed me that the command name is actually org-agenda. It also revealed a bunch of really useful documentation about how to customize org-adgenda using the org-adgenda-custom-commands variable.

I added the following snippet to my .emacs file:

(setq org-agenda-custom-commands
  '(("d" "Dave's Daily TODO List" tags "{.*}-someday-repeating/-DONE" nil nil)))

Now, when I use C-c a, the menu looks like this (with my custom command a the bottom):

 Press key for an agenda command:        <   Buffer,subtree/region restriction
 --------------------------------        >   Remove restriction
 a   Agenda for current week or day      e   Export agenda views
 t   List of all TODO entries            T   Entries with special TODO kwd
 m   Match a TAGS query                  M   Like m, but only TODO entries
 L   Timeline for current buffer         #   List stuck projects (!=configure)
 s   Search for keywords                 C   Configure custom agenda commands
 /   Multi-occur
 d   Dave's Daily TODO list: {.*}-someday-repeating/-DONE

I can use C-a d to get a list of next todo items.

This morning when I ran this command it showed that I should write a blog about customizing emacs commands. Thanks to Emacs org-mode, I can now cross that one off my list!

Tags: emacs tech