* [PATCH] Stop generating superfluous clock entries
@ 2009-11-27 2:21 Bernt Hansen
2009-11-27 7:09 ` Carsten Dominik
0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2009-11-27 2:21 UTC (permalink / raw)
To: emacs-orgmode; +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 <bernt@norang.ca>
+
+ * 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 <carsten.dominik@gmail.com>
* 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Stop generating superfluous clock entries
2009-11-27 2:21 [PATCH] Stop generating superfluous clock entries Bernt Hansen
@ 2009-11-27 7:09 ` Carsten Dominik
2009-11-28 16:07 ` [RFC/PATCH v3] " Bernt Hansen
0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2009-11-27 7:09 UTC (permalink / raw)
To: Bernt Hansen; +Cc: emacs-orgmode
Thanks, Bernt, good idea!
I have applied a modified version.
- Carsten
On Nov 27, 2009, at 3:21 AM, Bernt Hansen wrote:
> 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 <bernt@norang.ca>
> +
> + * 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 <carsten.dominik@gmail.com>
>
> * 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
>
>
>
> _______________________________________________
> 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
- Carsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC/PATCH v3] Stop generating superfluous clock entries
2009-11-27 7:09 ` Carsten Dominik
@ 2009-11-28 16:07 ` Bernt Hansen
2009-12-09 11:31 ` Bernt Hansen
0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2009-11-28 16:07 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Carsten Dominik
From: Carsten Dominik <carsten.dominik@gmail.com>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC/PATCH v3] Stop generating superfluous clock entries
2009-11-28 16:07 ` [RFC/PATCH v3] " Bernt Hansen
@ 2009-12-09 11:31 ` Bernt Hansen
0 siblings, 0 replies; 4+ messages in thread
From: Bernt Hansen @ 2009-12-09 11:31 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Carsten Dominik
Bernt Hansen <bernt@norang.ca> writes:
> From: Carsten Dominik <carsten.dominik@gmail.com>
>
> 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.
>
I've added the following patch on top of this one for my work flow. It
allows clocking in the same task and to update the modeline task name
and effort values. I've been using both of these patches for a week
with no problems.
Both patches are available at git://git.norang.ca/org-mode clock-in
--8<---------------cut here---------------start------------->8---
From 8f62f61aab3c1940b2a4e0fb73562d900568463c Mon Sep 17 00:00:00 2001
From: Bernt Hansen <bernt@norang.ca>
Date: Wed, 2 Dec 2009 11:40:42 -0500
Subject: [PATCH] Update modeline with effort and task name on re-clock-in
Skip clocking out when we are clocking in the same task that
is currently clocking but go through the normal clock-in
setup so a modified task name or effort property is
updated in the modeline.
---
lisp/org-clock.el | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 2d625ae..c13f4dd 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -857,7 +857,7 @@ the clocking selection, associated with the letter `d'."
;; 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
+ (if (save-excursion
(unless selected-task
(org-back-to-heading t))
(and (equal (marker-buffer org-clock-hd-marker)
@@ -868,12 +868,12 @@ the clocking selection, associated with the letter `d'."
(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))
+ (message "Clock continues in \"%s\"" org-clock-heading)
+ (progn
+ (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
--
1.6.6.rc1.39.g9a42
--8<---------------cut here---------------end--------------->8---
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-09 11:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-27 2:21 [PATCH] Stop generating superfluous clock entries Bernt Hansen
2009-11-27 7:09 ` Carsten Dominik
2009-11-28 16:07 ` [RFC/PATCH v3] " Bernt Hansen
2009-12-09 11:31 ` Bernt Hansen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).