From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: [RFC/PATCH v3] Stop generating superfluous clock entries Date: Sat, 28 Nov 2009 11:07:14 -0500 Message-ID: <1259424434-332-1-git-send-email-bernt@norang.ca> References: Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NEPpU-0005QI-Hp for emacs-orgmode@gnu.org; Sat, 28 Nov 2009 11:07:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NEPpQ-0005OX-Ao for emacs-orgmode@gnu.org; Sat, 28 Nov 2009 11:07:23 -0500 Received: from [199.232.76.173] (port=41187 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEPpQ-0005OU-5L for emacs-orgmode@gnu.org; Sat, 28 Nov 2009 11:07:20 -0500 Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:51620) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NEPpQ-0005TJ-0s for emacs-orgmode@gnu.org; Sat, 28 Nov 2009 11:07:20 -0500 In-Reply-To: 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: Carsten Dominik From: Carsten Dominik 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. --- Carsten, I think this patch works but I want to let it cook for a week or so before committing it in master. The previous patches had issues clocking in with a prefix when not in an org-mode buffer. I've squashed the previous two reverted commits into this patch and added a check to prevent org-back-to-heading if we are using a selected task. There is also some whitespace cleanup at the bottom. This makes C-u C-c C-x C-i work in the agenda and non-org-mode buffers again. lisp/org-clock.el | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index f598cc3..b79e66e 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -850,15 +850,29 @@ the clocking selection, associated with the letter `d'." (when interrupting ;; We are interrupting the clocking of a different task. ;; Save a marker to this task, so that we can go back. + ;; First check if we are trying to clock into the same task! + (when (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))))) + (message "Clock continues in \"%s\"" org-clock-heading) + (throw 'abort nil)) (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.61.g41d5b