In "how I get work done with Emacs and org-mode" I talked about how I manually
switch a task to
IN-PROGRESS when I start working on it. It's not a huge
inconvenience, but I did wonder if I could configure Emacs to do it for me.
Of course there's a feature for that.
There are two variables that can be used to configure org's behaviour when clocking time:
- The state to change a task to when clocking in.
- The state to change to when clocking out.
Both of these variables can either be a
string which will be the new state, or
they can be a function. If they're a function it must accept ONE parameter - the
task's current state - and return the state to switch to.
In practice it looks like this:
;; Always change the task to IN-PROGRESS. (setq org-clock-in-switch-to-state "IN-PROGRESS") ;; Use a function to decide what to change the state to. (setq org-clock-in-switch-to-state #'sodaware/switch-task-on-clock-start) (defun sodaware/switch-task-on-clock-start (task-state) "Change a task to 'IN-PROGRESS' when TASK-STATE is 'TODO'." (if (string= task-state "TODO") "IN-PROGRESS" task-state))
It's a small change, but it smooths out a slight wrinkle in my workflow.