Never Miss a Task Again: Tagging Org Mode TODOs by Context

Intro

Org Mode provides you with a number of useful tools for managing tasks and projects all from the comfort of Emacs. However, it doesn’t really tell you how to use these features together to create an effective productivity workflow.

Over the past year, I’ve been developing a strategy for assigning tags to TODO items in a way that ensures that I focus only on the tasks that matter right now. Today, I’m going to teach you how to do it too!

The Problem

Org Mode gives you the ability to mark any heading as a TODO item. These TODO items are a great way to keep a list of tasks for a project that you track in a specific Org file.

Typically what happens is that you create a few different Org files for your active projects or interests, fill them with a bunch of TODO items, and then forget to look at half of them.

The Org Agenda can help with this because it enables you to generate a view containing all TODO items across a number of Org files, but that can be pretty overwhelming and distracting when your task lists grow larger.

Luckily Org Mode offers a possible solution to this problem: adding tags to TODO items. Instead of looking at a huge list of TODO items, you can how have the Org Agenda filter those items down to a specific tag or a list of tags.

This works great, but to get the most out of tags and agenda views, you’ll have to spend some time designing a set of tags that will ensure you find the list of tasks that matter most for whatever you should be doing right now.

Designing Context Tags

My solution to this problem is to define context tags for the places, devices, and activities that are relevant to your day to day life so that they can be the anchor for the tasks that relate to a set of contexts.

Places

For example, the context tags for places could be @home or @work, but it also might be @pharmacy, @school, @grocery, or others depending on where you are on a daily basis.

The key here is to come up with a list of places where you often need to remember to do something. That way you can filter down your list of TODOs based on a place where you are right now or where you might be headed soon.

Devices

There are also tasks that might be done most effectively using a specific device, like a @computer or smart @phone.

Imagine that you’re waiting somewhere without a computer in front of you, but you have your smart phone handy. Wouldn’t it be nice if you knew which tasks you could take care of when you would otherwise be unproductive?

You may be wondering why I would include “computer” in this list since many kinds of actions can be performed with a computer. In my experience, there are times when I’m not sure what to do next but I can look at my list of “computer” tasks and find some things I would have forgotten to do otherwise.

You can also extend this to more specific computers like @server or @laptop, any device that may have tasks that can be done most effectively using that device.

Activities

For me, the most effective type of context tag is for the activities that I do on a regular basis.

For example, I regularly spend time writing, programming, working on creative projects like graphics or video, or even more broad activities like planning my day or running errands.

If I tag all the tasks related to a particular activity, I can very easily find all of the TODO items that I might want to remember when it’s time for that activity.

Instead of thinking “I’ll work on Project X today”, you can instead sit down for programming time and take a look at what tasks might be the best fit for the time you have available. This can really help you balance your time across projects and activties more effectively.

Here are some activity tags that might be helpful:

  • @programming
  • @writing
  • @creative
  • @email
  • @calls
  • @errands

Configuring Org Mode Tags

Now that we’ve thought about context tags, let’s take a look at how you would tell Org Mode about the tags you’ve designed so that they can be applied very efficiently when you create new tasks.

The key variable for this is org-tag-alist: it lets you define the list of tags along with a quick key binding for each tag to make them easy to assign.

This list can contain a simple series of strings that represent each tag, but it’s actually more efficient to assign a selection key so that you can choose that tag by pressing a single letter on the keyboard.

You can do this by using a “pair” for each entry with the left side as the name of the tag and the right side as the hot key to use to quickly select that tag.

Note that the “@” prefix that I use in the tag names is not special nor required, it is just a convention I use for the names of context tags because it sounds like “at home”, “at computer”, etc.

Here’s an example org-tag-alist setting from the tags we’ve come up with so far:

(setq org-tag-alist
      '(;; Places
        ("@home" . ?H)
        ("@work" . ?W)

        ;; Devices
        ("@computer" . ?C)
        ("@phone" . ?P)

        ;; Activities
        ("@planning" . ?n)
        ("@programming" . ?p)
        ("@writing" . ?w)
        ("@creative" . ?c)
        ("@email" . ?e)
        ("@calls" . ?a)
        ("@errands" . ?r))

Once we’ve set up our org-tags-alist, we will now be prompted with those tags when we try to set tags on a new task or filter

All of your tasks should be tagged! This is how you will remember to do them when the time is right. In another video, I’ll show you how to define a custom agenda view which will give you the list of untagged tasks so that none fall through the cracks.

Using the Agenda View

The Org Agenda provides a unified view for headings of different types across your Org files. You will need to set the org-agenda-files variable to a list of strings representing the paths to the Org files that you want to include in the agenda view, like this:

(setq org-agenda-files '("~/tmp/org-video/Notes/Personal.org"
                         "~/tmp/org-video/Notes/Projects.org"
                         "~/tmp/org-video/Notes/Work.org"))

Once you have this variable configured, you can use M-x org-agenda to launch the Org Agenda view to see all of your TODO items across all of the agenda files. There are many pre-configured agenda views, but we will press t to pick the TODO view.

You can filter it down to only the tasks that are relevant to your current context by pressing the / key and then typing in the name of the tag you want to filter by. You can also use TAB to complete the names of tags you configured in org-tag-alist!

I’ll go into more detail on the agenda view in future videos.

Efficiently Tagging Tasks

Now that you know how to filter TODO items by their tags, let’s learn how to quickly add and change tags that are assigned to a TODO item.

To create a new TODO item in an Org buffer, you can press M-S-RET (Alt+Shift+Enter) to create a new TODO heading. You can then press C-c C-q to set the tags on the current TODO item under the cursor.

This popup prompt will present you with all of the tags you’ve configured in org-tag-alist and you can use the hotkeys we configured (the configured ? key for each tag) to select the tags to apply to that item. You can also edit and clear tags using the keys presented in the prompt.

You should now be able to quickly add and tag new TODO items so that they show up in your filtered agenda views for each context!

Conclusion

You can download the example Org files and configuration that we looked at in today’s video by clicking on this link in the show notes:

https://systemcrafters.net/files/org-context-tags.zip

Until next time, Happy Hacking!

Subscribe to the System Crafters Newsletter!
Stay up to date with the latest System Crafters news and updates! Read the Newsletter page for more information.
Name (optional)
Email Address