TIL managing state switch in the absence of keywords in org mode
Written by Sebastian Dümcke on
Tags: TIL
In my init.el
file I had the line
(setq org-clock-in-switch-to-state "IN_PROGRESS")
Having an IN_PROGRESS
keyword between TODO
and DONE
helps me keep track of the task I am currently working on. However I noticed that when I started defining capture templates with :clock-in t
the task would be marked IN_PROGRESS
right away (even in the case it had no TODO keyword associated). To guard against this I found out that you can pass a function to org-clock-in-switch-to-state
. I now use the following function:
(defun samd/clock-in-switch-state (kw) "Switch to IN_PROGRESS unless we are in capture mode or there is no TODO kw assigned" (when (and kw (not (and (boundp 'org-capture-mode) org-capture-mode))) "IN_PROGRESS"))
The function checks if we are in capture mode and if the current heading has a TODO keyword. It will only switch the state to IN_PROGRESS
on a heading with a TOD keyword when clocking outside of capture mode.