From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Riley Subject: Re: clock based context settings Date: Wed, 20 Jan 2010 10:34:14 +0100 Message-ID: References: <4b562f2a.0c07560a.206e.ffff99b6@mx.google.com> <873a21rxe6.wl%maus.david@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXWxa-00018e-0S for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 04:34:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXWxV-00017t-Ip for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 04:34:45 -0500 Received: from [199.232.76.173] (port=54203 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXWxV-00017q-A3 for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 04:34:41 -0500 Received: from lo.gmane.org ([80.91.229.12]:33608) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NXWxV-0008CK-0L for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 04:34:41 -0500 Received: from list by lo.gmane.org with local (Exim 4.50) id 1NXWxR-0003Fs-Dk for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 10:34:37 +0100 Received: from 85.183.18.158 ([85.183.18.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 20 Jan 2010 10:34:37 +0100 Received: from rileyrgdev by 85.183.18.158 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 20 Jan 2010 10:34:37 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org David Maus writes: > --===============0364025519== > Content-Type: multipart/signed; > boundary="pgp-sign-Multipart_Wed_Jan_20_09:30:37_2010-1"; > protocol="application/pgp-signature" > Content-Transfer-Encoding: 7bit > > --pgp-sign-Multipart_Wed_Jan_20_09:30:37_2010-1 > Content-Type: text/plain; charset=US-ASCII > > Hi Richard, > > At Tue, 19 Jan 2010 23:16:08 +0100, > Richard Riley wrote: >> >> >> I would like to be able to execute arbitrary elisp when I clock in or >> out of a certain org.item This would be very, very useful for defining >> variables or even keystrokes on a "per project" basis. Ideally it would >> work using inheritance so if an item does not have something then the >> project or file level values would be used. >> >> e.g at the file level: >> >> #+CLOCKINEXEC: (setq curr-url "project1.com") >> >> Or at the org item level >> >> ** touch up picture of the org logo >> :PROPERTIES: >> :CLOCKINEXEC: (setq curr-url "org-mode.com/images") >> :END: >> >> Would others think this might be useful or is there another way/approach >> to achieve something similar? > > You could use the org-clock-hooks `org-clock-in-hook', > `org-clock-out-hook' and `org-clock-cancel-hook' in combination with a > function that checks for the desired conditions and sets the variables > accordingly. No variables or conditions. Just exec the block. > > A question that came in my mind: What happens if you clock out or > cancel a clock? Are the variables kept or set to a default value? Or > to the value they had before clocking in? Neither. I had thought to keep it easy - globals/whatever set by both clockin and clockout - its up to you to ensure that the elisp in your in/out code properties "do it right". They are nothing more than single elisp snippets. Probably a progn sequence or equivalent But then I dont know too much about things like local/global scope in elisp. ie can I create some sort of specific "object" and tack these value on and have them all just vanish when clockout occurs? Even then I could see that clock in/out code (:CLOCKOUTEXEC:) would probably set things globally frequently. Limited experience with elisp and how it all hangs together makes it hard for me to pinpoint what might be the best approach. e.g globals set (if you so want) or can we provide something with more localisation on a per task basis to complement/simplify the code? ie perhaps CLOCKINEXEC is "(progn (org-with-current-task-set-var "url" "ibm.com")(setq myGlobal nil)) and elsewhere a hot key invokes (browse-url (org-with-current-task-get "url")). I dont know to be honest what the "elisp/emacs" paradigm/approach is to things like that. Just chewing the cud at this stage;) -- Google Talk : rileyrgdev@googlemail.com http://www.google.com/talk