onilog

org-agenda-prefix-format

4 December 2012 1:33 AM (emacs | org-mode | config)

I've been looking for a way to clearly identify my projects from within an org-mode agenda todo buffer, and a little while ago I finally came across a nice way to do this: org-agenda-prefix-format.

The problems with other options I could think of were that the category just doesn't feel like the right place to put it, that should be an indication of what kind of todo item it is, not what it's for. Tags get messy very quickly and separate files are shown when no category has been given and using a lot of files can slow list generation down.

Setting it to a value like, for example:

((agenda . " %i %-12:c%?-12t% s")
 (timeline . "  % s")
 (todo .
  " %i %-12:c %(concat \"[ \"(org-format-outline-path (org-get-outline-path)) \" ]\") ")
 (tags .
  " %i %-12:c %(concat \"[ \"(org-format-outline-path (org-get-outline-path)) \" ]\") ")
 (search . " %i %-12:c"))

Will give me lines like:

task:        [ Blog ] TODO Blog about something
task:        [ Blog ] TODO Blog about something else

Where task is the category, Blog is the project, which is defined by being its one and only parent, and TODO is, of course, its todo state. The rest being the headline for the task.

Of course, with these settings you need to have exactly 2 levels of tasks, otherwise, I think, you'll get [ Blog/heading ], which might also be useful, but will grow big quickly.

I also only use this setting with todo and tags, because I don't usually need it for the items that show up in agenda and I don't really use timeline or search too much, but have a look at the documentation for org-agenda-prefix-format, you might think of something to do with it.

2 responses

  1. AP says:

    Hi, I tried to do the same for the agenda lines, but for some reason I cannot get it to work. Any ideas? I keep getting a "Before headline at position 32 in buffer" error.

  2. Tom says:

    No sorry, not with only that information. The error you sent makes me think that something is looking beyond the scope of your headlines.

    Which version of emacs and org-mode are you using? And can you show me an example of a file where it goes wrong for you?

Leave a Reply