* changing to IN-PROGRESS starts clocking it
@ 2016-04-20 8:15 Sharon Kimble
[not found] ` <cvsjucxe3u.ln2@news.c0t0d0s0.de>
0 siblings, 1 reply; 2+ messages in thread
From: Sharon Kimble @ 2016-04-20 8:15 UTC (permalink / raw)
To: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 375 bytes --]
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?
Any ideas please?
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: changing to IN-PROGRESS starts clocking it
[not found] ` <cvsjucxe3u.ln2@news.c0t0d0s0.de>
@ 2016-04-20 17:42 ` Sharon Kimble
0 siblings, 0 replies; 2+ messages in thread
From: Sharon Kimble @ 2016-04-20 17:42 UTC (permalink / raw)
To: Michael Welle; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]
Michael Welle <mwe012008@gmx.net> writes:
> Hello,
>
> Sharon Kimble <boudiccas@skimble.plus.com> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-20 17:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-20 8:15 changing to IN-PROGRESS starts clocking it Sharon Kimble
[not found] ` <cvsjucxe3u.ln2@news.c0t0d0s0.de>
2016-04-20 17:42 ` Sharon Kimble
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).