Emacs Org: Task-related keyboard shortcuts for the agenda

I really love the way you can tweak Emacs’ keyboard shortcuts and functionality to fit the way you want to work. Here are three keyboard shortcuts I’ve added to my Org agenda to make it even easier to work with tasks.

x: Mark the current task as done. Same as typing t x, but somehow it feels like it has more oomph as a single-character shortcut.

X: Mark the current task as done and create a new task at the same level, taking advantage of the task template I’d previously created in org-capture-templates.

N: Create a new note or task at the current position.

Make it easy to mark a task as done

(defun sacha/org-agenda-done (&optional arg)
  "Mark current TODO as done.
This changes the line at point, all other lines in the agenda referring to
the same tree node, and the headline of the tree node in the Org-mode file."
  (interactive "P")
  (org-agenda-todo "DONE"))
;; Override the key definition for org-exit
(define-key org-agenda-mode-map "x" 'sacha/org-agenda-done)

Make it easy to mark a task as done and create a follow-up task

  (defun sacha/org-agenda-mark-done-and-add-followup ()
    "Mark the current TODO as done and add another task after it.
Creates it at the same level as the previous task, so it's better to use
this with to-do items than with projects or headings."
    (interactive)
    (org-agenda-todo "DONE")
    (org-agenda-switch-to)
    (org-capture 0 "t"))
;; Override the key definition
(define-key org-agenda-mode-map "X" 'sacha/org-agenda-mark-done-and-add-followup)

Capture something based on the agenda position

(defun sacha/org-agenda-new ()
  "Create a new note or task at the current agenda item.
Creates it at the same level as the previous task, so it's better to use
this with to-do items than with projects or headings."
  (interactive)
  (org-agenda-switch-to)
  (org-capture 0))
;; New key assignment
(define-key org-agenda-mode-map "N" 'sacha/org-agenda-new)

Check out my Emacs configuration for other ideas.

  • olberger

    Btw, I’ve juste discovered the ‘k c’ agenda view action that allows you to capture SCHEDULED tasks right from the agenda. See more details at http://www.olivierberger.com/weblog/index.php?post/2013/01/16/Scheduling-appointments-with-capture-template-from-org-agenda-view

    Thanks for your post, that triggered my curiosity to try and search for a way to schedule todos from the agenda ;)

  • Carsten

    Hey Sacha, these are cool, thanks!

    – Carsten

  • Friedel

    This just inspired me to add

    (“x” org-todo “DONE”)

    to org-speed-commands-user

  • Ury Marshak

    It’s useful to have a quick link in a task to the one it’s based on. So
    for marking as done and creating a follow-up I use the following:(defun mark-done-and-open-new-linked ()  (interactive)  (org-todo ‘done)  (org-add-log-note)  (org-capture nil “l”))Where in org-capture-templates there is a corresponding entry:(“l” “Todo + link” entry (file+headline ,org-default-capture-file “Tasks”)
             “* TODO %?%i  %^gn  Ref:%an  Added:%U”
                 :prepend t)This way the new task has a link that can be quickly followed to original. Now it’s a nice idea to make it work in the agenda as per your sacha/org-agenda-mark-done-and-add-followup