From: Sharon Kimble <boudiccas@skimble.plus.com>
To: Michael Welle <mwe012008@gmx.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: changing to IN-PROGRESS starts clocking it
Date: Wed, 20 Apr 2016 18:42:49 +0100 [thread overview]
Message-ID: <87oa94nply.fsf@skimble.plus.com> (raw)
In-Reply-To: <cvsjucxe3u.ln2@news.c0t0d0s0.de> (Michael Welle's message of "Wed, 20 Apr 2016 10:58:52 +0200")
[-- 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 --]
prev parent reply other threads:[~2016-04-20 17:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oa94nply.fsf@skimble.plus.com \
--to=boudiccas@skimble.plus.com \
--cc=emacs-orgmode@gnu.org \
--cc=mwe012008@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).