From 29d945720095a65852f69b7c628c1199eb4961fe Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 27 Nov 2009 08:09:10 +0100 Subject: [PATCH] Stop generating superfluous clock entries 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. --- lisp/org-clock.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index fa3af7457..12f1c99c4 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -854,15 +854,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))) -- 2.11.4.GIT