From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: [PATCH] Stop generating superfluous clock entries Date: Thu, 26 Nov 2009 21:21:18 -0500 Message-ID: <1259288478-29642-1-git-send-email-bernt@norang.ca> Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDqSi-00044l-Jo for emacs-orgmode@gnu.org; Thu, 26 Nov 2009 21:21:32 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDqSf-00041L-6z for emacs-orgmode@gnu.org; Thu, 26 Nov 2009 21:21:32 -0500 Received: from [199.232.76.173] (port=54618 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDqSe-00041G-Ut for emacs-orgmode@gnu.org; Thu, 26 Nov 2009 21:21:28 -0500 Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:57932) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NDqSe-0002oV-QY for emacs-orgmode@gnu.org; Thu, 26 Nov 2009 21:21:28 -0500 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 1NDqSe-000JkZ-1P for emacs-orgmode@gnu.org; Fri, 27 Nov 2009 02:21:28 +0000 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 Avoid closing the currently clocking entry when clocking in the same task again. Leave the clock entry open until some other task is clocked in. This allows us to clock in tasks with hooks that are called frequently without generating lots of short sequential clock entries for the same task. --- This patch is available at git://git.norang.ca/org-mode.git clock-in I haven't extensively tested this but it seems to work for for me. I currently have clock resolution disabled. lisp/ChangeLog | 5 +++++ lisp/org-clock.el | 29 ++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4acb99c..ecba8f7 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-11-26 Bernt Hansen + + * org-clock.el (org-clock-in): Avoid creating superfluous clock + entries when clocking in the task that is already running. + 2009-11-26 Carsten Dominik * org-footnote.el (org-footnote-normalize): Don't take optional diff --git a/lisp/org-clock.el b/lisp/org-clock.el index f598cc3..9bfe53e 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -847,18 +847,29 @@ the clocking selection, associated with the letter `d'." (if selected-task (setq selected-task (copy-marker selected-task)) (error "Abort"))) - (when interrupting - ;; We are interrupting the clocking of a different task. - ;; Save a marker to this task, so that we can go back. - (move-marker org-clock-interrupted-task - (marker-position org-clock-marker) - (marker-buffer org-clock-marker)) - (org-clock-out t)) - + + (let ((current-hd-marker (make-marker))) + ; Find the heading for the current point + (move-marker current-hd-marker + (save-excursion + (org-back-to-heading t) + (point)) + (buffer-base-buffer)) + ; Do not clock out if we want to clock in the task + ; that is currently clocking + (when interrupting + (unless (equal current-hd-marker org-clock-hd-marker) + ;; We are interrupting the clocking of a different task. + ;; Save a marker to this task, so that we can go back. + (move-marker org-clock-interrupted-task + (marker-position org-clock-marker) + (marker-buffer org-clock-marker)) + (org-clock-out t)))) + (when (equal select '(16)) ;; Mark as default clocking task (org-clock-mark-default-task)) - + ;; Clock in at which position? (setq target-pos (if (and (eobp) (not (org-on-heading-p))) -- 1.6.6.rc0.54.gb073b