From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: [PATCH] Set org-clock-clocking-in when calling org-clock-out from org-clock-in Date: Thu, 20 May 2010 12:20:20 -0400 Message-ID: <1274372420-6164-1-git-send-email-bernt@norang.ca> References: <871vd64m0q.fsf@gollum.intra.norang.ca> Return-path: Received: from [140.186.70.92] (port=35148 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF8U5-0004Lu-6h for emacs-orgmode@gnu.org; Thu, 20 May 2010 12:20:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OF8Tz-0004uJ-Ae for emacs-orgmode@gnu.org; Thu, 20 May 2010 12:20:33 -0400 Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:54312) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OF8Tz-0004uC-75 for emacs-orgmode@gnu.org; Thu, 20 May 2010 12:20:27 -0400 Received: from cpe000102d0fe75-cm0012256ecbde.cpe.net.cable.rogers.com ([99.239.148.180] helo=mail.norang.ca) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1OF8Ty-000GHi-FJ for emacs-orgmode@gnu.org; Thu, 20 May 2010 16:20:26 +0000 In-Reply-To: <871vd64m0q.fsf@gollum.intra.norang.ca> 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 Cc: Bernt Hansen org-clock-out-hook can now query org-clock-clocking-in to see if org-clock-out is being called inside org-clock-in. This allows the hook to selectively clock in another task without leaving clocks open. --- Here's the updated patch which seems to work just as well. This patch is available at git://git.norang.ca/org-mode.git persistent-clocking Most of the changes here are whitespace. The very last change in the patch is the only interesting part. -Bernt lisp/org-clock.el | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 68a40ce..dbcd032 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -925,7 +925,7 @@ the clocking selection, associated with the letter `d'." (org-clocking-p))) ts selected-task target-pos (msg-extra "") (leftover (and (not org-clock-resolving-clocks) - org-clock-leftover-time))) + org-clock-leftover-time))) (when (and org-clock-auto-clock-resolution (or (not interrupting) (eq t org-clock-auto-clock-resolution)) @@ -944,22 +944,23 @@ the clocking selection, associated with the letter `d'." ;; Save a marker to this task, so that we can go back. ;; First check if we are trying to clock into the same task! (if (save-excursion - (unless selected-task - (org-back-to-heading t)) - (and (equal (marker-buffer org-clock-hd-marker) - (if selected-task - (marker-buffer selected-task) - (current-buffer))) - (= (marker-position org-clock-hd-marker) - (if selected-task - (marker-position selected-task) - (point))))) + (unless selected-task + (org-back-to-heading t)) + (and (equal (marker-buffer org-clock-hd-marker) + (if selected-task + (marker-buffer selected-task) + (current-buffer))) + (= (marker-position org-clock-hd-marker) + (if selected-task + (marker-position selected-task) + (point))))) (message "Clock continues in \"%s\"" org-clock-heading) (progn (move-marker org-clock-interrupted-task (marker-position org-clock-marker) (org-clocking-buffer)) - (org-clock-out t)))) + (let ((org-clock-clocking-in t)) + (org-clock-out t))))) (when (equal select '(16)) ;; Mark as default clocking task -- 1.7.1.86.g0e460