[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] changing to IN-PROGRESS starts clocking it
From: |
Sharon Kimble |
Subject: |
Re: [O] changing to IN-PROGRESS starts clocking it |
Date: |
Wed, 20 Apr 2016 18:42:49 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) |
Michael Welle <address@hidden> writes:
> Hello,
>
> Sharon Kimble <address@hidden> writes:
>
>> How can I have a task which when I change its state from TODO or NEXT to
>> IN-PROGRESS starts clocking it until its state is changed back from
>> IN-PROGRESS to some other state, when the clocking will cease?
>
> you can utilise the org-after-todo-state-change-hook. Something like
> this should do the trick:
>
> (defun foo ()
> (when (and (string= org-state "IN-PROGRESS")
> (string= org-last-state "TODO")
> (not (string= org-last-state org-state)))
> (org-clock-in)))
>
> (add-hook 'org-after-todo-state-change-hook 'foo)
>
> The same mechanism can be used to clock out again.
>
Thanks Michael, it works very well. This is the actual coding that I
used -
--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
(defun org-clockin ()
(when (and (string= org-state "IN-PROGRESS")
(string= org-last-state "TODO")
(not (string= org-last-state org-state)))
(org-clock-in)))
(add-hook 'org-after-todo-state-change-hook 'org-clockin)
#+end_src
#+begin_src emacs-lisp
(defun org-clockout ()
(when (and (string= org-state "TODO")
(string= org-last-state "IN-PROGRESS")
(not (string= org-last-state org-state)))
(org-clock-out)))
(add-hook 'org-after-todo-state-change-hook 'org-clockout)
#+end_src
--8<---------------cut here---------------end--------------->8---
Thanks
Sharon.
--
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
Debian 8.4, fluxbox 1.3.7, emacs 25.0.92
signature.asc
Description: PGP signature