From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: [Patch] org-clock-current-task Date: Wed, 24 Feb 2010 15:59:23 +0100 Message-ID: <87ljeiu1bo.fsf@bzg.ath.cx> References: <87tyt6u296.fsf@bzg.ath.cx> <26468BB6-A290-4344-ABB9-8DD8E876244A@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NkIi6-0001DP-Te for emacs-orgmode@gnu.org; Wed, 24 Feb 2010 09:59:34 -0500 Received: from [140.186.70.92] (port=59466 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkIi5-0001D5-F2 for emacs-orgmode@gnu.org; Wed, 24 Feb 2010 09:59:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NkIi4-0002XL-6O for emacs-orgmode@gnu.org; Wed, 24 Feb 2010 09:59:33 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:58783) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NkIi4-0002X6-0Z for emacs-orgmode@gnu.org; Wed, 24 Feb 2010 09:59:32 -0500 Received: by pwj7 with SMTP id 7so5022797pwj.0 for ; Wed, 24 Feb 2010 06:59:30 -0800 (PST) In-Reply-To: <26468BB6-A290-4344-ABB9-8DD8E876244A@gmail.com> (Carsten Dominik's message of "Wed, 24 Feb 2010 15:43:09 +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: Carsten Dominik Cc: emacs-orgmode@gnu.org --=-=-= Carsten Dominik writes: > Yes, please go ahead. Thanks. Attached is more complete version: now clocking out will set the content of `org-clock-current-task' to nil. It occurs to me that such a simple functionnality could also use hooks. What do you think ? Is it better to include it in the code or to simply put the hooks on Worg? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org-clock.el.diff diff --git a/lisp/org-clock.el b/lisp/org-clock.el index e3866be..cb378e6 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -944,6 +944,7 @@ the clocking selection, associated with the letter `d'." (org-back-to-heading t) (or interrupting (move-marker org-clock-interrupted-task nil)) (org-clock-history-push) + (org-clock-set-current) (cond ((functionp org-clock-in-switch-to-state) (looking-at org-complex-heading-regexp) (let ((newstate (funcall org-clock-in-switch-to-state @@ -1042,6 +1043,15 @@ the clocking selection, associated with the letter `d'." (message "Clock starts at %s - %s" ts msg-extra) (run-hooks 'org-clock-in-hook))))))) +(defvar org-clock-current-task nil + "Task currently clocked in.") +(defun org-clock-set-current () + "Set `org-clock-current-task' to the task currently clocked in." + (setq org-clock-current-task (org-get-heading))) +(defun org-clock-delete-current () + "Reset `org-clock-current-task' to nil." + (setq org-clock-current-task nil)) + (defun org-clock-mark-default-task () "Mark current task as default task." (interactive) @@ -1237,7 +1247,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (force-mode-line-update) (message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m (if remove " => LINE REMOVED" "")) - (run-hooks 'org-clock-out-hook)))))) + (run-hooks 'org-clock-out-hook) + (org-clock-delete-current)))))) (defun org-clock-cancel () "Cancel the running clock be removing the start timestamp." --=-=-= -- Bastien --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--