From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sharon Kimble Subject: Re: changing to IN-PROGRESS starts clocking it Date: Wed, 20 Apr 2016 18:42:49 +0100 Message-ID: <87oa94nply.fsf@skimble.plus.com> References: <87ega01yrw.fsf@skimble.plus.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asw9X-0001Nc-1B for emacs-orgmode@gnu.org; Wed, 20 Apr 2016 13:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asw9T-0005OA-Po for emacs-orgmode@gnu.org; Wed, 20 Apr 2016 13:43:02 -0400 Received: from avasout05.plus.net ([84.93.230.250]:48443) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asw9T-0005NG-JW for emacs-orgmode@gnu.org; Wed, 20 Apr 2016 13:42:59 -0400 In-Reply-To: (Michael Welle's message of "Wed, 20 Apr 2016 10:58:52 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Michael Welle Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Michael Welle writes: > Hello, > > Sharon Kimble 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=3D org-state "IN-PROGRESS") > (string=3D org-last-state "TODO") > (not (string=3D 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 - =2D-8<---------------cut here---------------start------------->8--- #+begin_src emacs-lisp (defun org-clockin () (when (and (string=3D org-state "IN-PROGRESS") (string=3D org-last-state "TODO") (not (string=3D 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=3D org-state "TODO") (string=3D org-last-state "IN-PROGRESS") (not (string=3D org-last-state org-state))) (org-clock-out))) (add-hook 'org-after-todo-state-change-hook 'org-clockout) #+end_src =2D-8<---------------cut here---------------end--------------->8--- Thanks Sharon. =2D-=20 A taste of linux =3D http://www.sharons.org.uk TGmeds =3D http://www.tgmeds.org.uk Debian 8.4, fluxbox 1.3.7, emacs 25.0.92 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJXF7+ZAAoJEDaBgBkK+INbj0cP/igpK3DwXggOGeNr8MySW0AF 8ZqAQ+aThtfsvI84lndTUNv7jSDbUOe+tQNm7Q4R2apUWsIgMRHNK2WJdzcIApuo pXBNV8wIzGsm7zb4rwGVrDZmrpMMS+dB8IPLXPGnrxm8UzeBCap3WShJQ4OaTTVF Qe2Urldk3L/a/3o+2B7GtHNNVkkbBAdqOkwxV4z0rADYViFxlWOU/FFxdbXlWCaJ xpsRR4IMBsO1vuIzQ4I7UApFp4wtcYrzjQm5kq25J7jovuYIUfhchoRSrXssfCdn uNiDIhzb6ya6awr2ls1Q7n/bvNW8lS/4HaOunTKAvHxCqPLPSNgBDgN51KhN7x52 ET6jvj373fAzkMe4DqriRO+oHkQvPhQr3JgzFcA6d+U3W2q7xrEv9o+Ari1q58hO AALh3+5OifoREceUoVLWYEyqgsohI9BYUpr+aNImYYG9/qKJvtc5FJTcCJjgbaZw 3C/ZchzlalgM0Adnrq8oov1cMmBC0axwmomoyUd4y1SdOALo/dr5jPRRIpco1dsa +mUUQOplwioeUPLoNI6pf/R3c3TR6N3UeQpM4/+9l4FpkfURb8yQszRvpR8Qv3Vt Cagf25+wEqafyRXVM5FLa4QkDeAobbCxQj/aehGKH/ngy1Zyz4fvp1542vPx0Bp+ swOsxRVyKrvP1PfFvd7s =KroW -----END PGP SIGNATURE----- --=-=-=--