Building an Org-mode Workflow: Priority Cookies

by Jeff Bradberry

As I came to track more and more items using Org mode, I realized that I needed to have a way of raising up items or filtering down to the things I should be concentrating on. I needed prioritization.

My first known use of this feature dates to 4 Jan 2023.

Usage

Priority cookies are just a bit of extra text that goes between the TODO or other tag at the beginning of a headline, and the text of the headline. They are placed between square brackets, and are prefaced with a # character. It gets formatted like so:

** TODO [#B] look over 13398 and 6253

These priority cookies can, of course, be manually typed, but there are also keybindings that allow you to set them. The ones I usually use are S-UP (to raise the priority) or S-DOWN (to lower it). You can also use C-c ,, which prompts you for the level to directly set it (or unset, using SPC) instead of having to cycle through. These keybindings work in the agenda view as well as directly in the org file.

As indicated in the docs, priorities are only meaningful for sorting items in the agenda views. They have no other inherent meaning.

By default, Org mode provides three levels of priority: A, B, and C. I have two problems with this, though. I strongly prefer numeric priorities, and I want more than just three. Fortunately, Org allows you to configure this to any slice of (ASCII?) characters in lexicographic order. I chose to use 1 through 5, with 4 as the default.

(setq org-priority-highest 1
      org-priority-lowest  5
      org-priority-default 4)

Why did I chose to do it this way? Here's what I mean by it. Choices 1 through 3 remain priorities high, medium, and low. Choice 4 is my personal unrefined backlog items -- I may get around to looking at them at some point, but for now I just want them captured. And choice 5 is special -- I use it to bury items that I don't want to notice in the non-time-based agenda views (C-c a t and similar). These are things like recurring tasks or items that I believe I will never find time to work on. Why did I want to do this? Because, todo items that don't have a priority cookie on them implicitly get treated as the default priority (in my case 4). I wanted to have a priority that is explicitly lower than that, in order to sort those items to the absolute bottom of the list.

Here's an excerpt of what this looks like in my C-c a t agenda view.

...
projects:   TODO [#3] Update Python version of MCTS to cache the selection phase                                                                                     :programming::
projects:   TODO [#3] Rust version of MCTS                                                                                                                      :programming::rust:
projects:   TODO [#3] fix tables in the org-mode lexer for pygments                                                                                                     :blog::org:
projects:   TODO [#3] create styling for various admonition blocks, similar to how Sphinx does it                                                                           :blog::
projects:   TODO [#3] add converting an ordinary list item into a checkbox to Post 4                                                                                        :blog::
projects:   TODO [#3] Post #7 - Logging notes                                                                                                                           :blog::org:
projects:   TODO [#3] Post #8 - Capture Templates                                                                                                                       :blog::org:
projects:   TODO [#3] Post #9 - Executable Blocks                                                                                                                       :blog::org:
projects:   TODO [#3] Post #10 - Tables & Table Processing                                                                                                              :blog::org:
projects:   TODO [#3] Post #?? - Org-roam                                                                                                                               :blog::org:
projects:   TODO [#3] Post #?? - Project Cycling                                                                                                                        :blog::org:
projects:   TODO Capture the New Orleans passenger lists                                                                                                               :genealogy::
projects:   TODO Capture the WPA New Orleans transcribed copies                                                                                                        :genealogy::
projects:   TODO [#4] try out one of the Rust ECS frameworks to implement a skeleton version                                                                    :programming:rust::
home:       TODO [#5] Pay bills                                                                                                                                            :bills::
projects:   TODO [#5] renew jeffbradberry.com                                                                                                                      :sysadmin:blog::
projects:   TODO [#5] renew certs for jeffbradberry.com                                                                                                            :sysadmin:blog::
...

Notice that the unprioritized items get sorted along with the [#4] item.

It is also possible to filter by priority in agenda views, using C-c a m or C-c a M, and then type in a filter, e.g. PRIORITY=2.

Settings

  • org-priority-highest: The beginning of the priority sequence, and the highest priority.
  • org-priority-lowest: The end of the sequence, and the lowest priority.
  • org-priority-default: The character that the sequence will start with when using the keybindings, and the priority that unprioritized items will be treated as when sorting in the agenda views.

At this point my org-mode section in .emacs looks like this:

(global-set-key (kbd "C-c l") #'org-store-link)
(global-set-key (kbd "C-c a") #'org-agenda)
(global-set-key (kbd "C-c c") #'org-capture)

(setq org-startup-folded 'showall
      org-agenda-files   (list "~/org/")
      org-refile-targets '((org-agenda-files :maxlevel . 5))
      org-refile-use-outline-path 'file
      org-log-into-drawer t
      org-log-done 'time
      org-log-redeadline 'time
      org-log-reschedule 'time
      org-priority-highest 1
      org-priority-lowest  5
      org-priority-default 4
)

Key Bindings Learned

  • S-UP: cycle upward through the priorities
  • S-DOWN: cycle downward through the priorities
  • C-c ,: set a specific cookie value, SPC to remove
  • C-c a m and C-c a M: search for items with a given priority, using a search term of the form PRIORITY=X.

Next Steps

I started to want a finer-grained accounting of what I was doing than having a bunch of hierarchical headlines or manual notes drawers was giving me. Next time, I'll talk about adding timestamped note logging to my workflow.