emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] clock reports: Only include current clocking task when range includes task
@ 2010-05-17  2:05 Bernt Hansen
  2010-05-17  2:09 ` Bernt Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Bernt Hansen @ 2010-05-17  2:05 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

When org-clock-report-include-clocking-task is set we always add the
current clocking task to the clock report.  This is incorrect if you
are looking at an agenda clock report for a time range that does not
include the current clocking task (e.g. yesterday or last week).

Now we only include the current clocking task if the clock report
date range includes the current clocking task start time.
---
This patch is available at git://git.norang.ca for-carsten

 lisp/org-clock.el |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 504f0c9..e999690 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1396,12 +1396,16 @@ nil are excluded from the clock summation."
 		      (* 60 (string-to-number (match-string 4))))))
 	 (t ;; A headline
 	  ;; Add the currently clocking item time to the total
-	  (when (and org-clock-report-include-clocking-task
-		     (equal (org-clocking-buffer) (current-buffer))
-		     (equal (marker-position org-clock-hd-marker) (point)))
+	  (let ((org-clock-start-time-as-float (org-float-time org-clock-start-time)))
+	    (message "clock test %s %s %s" tstart org-clock-start-time-as-float tend)
+	    (when (and org-clock-report-include-clocking-task
+		       (equal (org-clocking-buffer) (current-buffer))
+		       (equal (marker-position org-clock-hd-marker) (point))
+		       (>= org-clock-start-time-as-float tstart)
+		       (<= org-clock-start-time-as-float tend))
 	      (let ((time (floor (- (org-float-time)
-				    (org-float-time org-clock-start-time)) 60)))
-		(setq t1 (+ t1 time))))
+				    org-clock-start-time-as-float) 60)))
+		(setq t1 (+ t1 time)))))
 	  (let* ((headline-forced
                   (get-text-property (point)
                                      :org-clock-force-headline-inclusion))
-- 
1.7.1.86.g0e460

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] clock reports: Only include current clocking task when range includes task
  2010-05-17  2:05 [PATCH] clock reports: Only include current clocking task when range includes task Bernt Hansen
@ 2010-05-17  2:09 ` Bernt Hansen
  2010-05-17  2:12   ` Bernt Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Bernt Hansen @ 2010-05-17  2:09 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt@norang.ca> writes:

> When org-clock-report-include-clocking-task is set we always add the
> current clocking task to the clock report.  This is incorrect if you
> are looking at an agenda clock report for a time range that does not
> include the current clocking task (e.g. yesterday or last week).
>
> Now we only include the current clocking task if the clock report
> date range includes the current clocking task start time.
> ---
> This patch is available at git://git.norang.ca for-carsten

Disregard this patch - it has a debug call to (message) in it.  New one
coming shortly.

-Bernt

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] clock reports: Only include current clocking task when range includes task
  2010-05-17  2:09 ` Bernt Hansen
@ 2010-05-17  2:12   ` Bernt Hansen
  2010-05-17  9:36     ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Bernt Hansen @ 2010-05-17  2:12 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

When org-clock-report-include-clocking-task is set we always add the
current clocking task to the clock report.  This is incorrect if you
are looking at an agenda clock report for a time range that does not
include the current clocking task (e.g. yesterday or last week).

Now we only include the current clocking task if the clock report
date range includes the current clocking task start time.
---
 Update patch without the debug call to the (message)

 This patch is available at git://git.norang.ca/org-mode.git for-carsten

 -Bernt

 lisp/org-clock.el |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 504f0c9..07e2e45 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1396,12 +1396,15 @@ nil are excluded from the clock summation."
 		      (* 60 (string-to-number (match-string 4))))))
 	 (t ;; A headline
 	  ;; Add the currently clocking item time to the total
-	  (when (and org-clock-report-include-clocking-task
-		     (equal (org-clocking-buffer) (current-buffer))
-		     (equal (marker-position org-clock-hd-marker) (point)))
+	  (let ((org-clock-start-time-as-float (org-float-time org-clock-start-time)))
+	    (when (and org-clock-report-include-clocking-task
+		       (equal (org-clocking-buffer) (current-buffer))
+		       (equal (marker-position org-clock-hd-marker) (point))
+		       (>= org-clock-start-time-as-float tstart)
+		       (<= org-clock-start-time-as-float tend))
 	      (let ((time (floor (- (org-float-time)
-				    (org-float-time org-clock-start-time)) 60)))
-		(setq t1 (+ t1 time))))
+				    org-clock-start-time-as-float) 60)))
+		(setq t1 (+ t1 time)))))
 	  (let* ((headline-forced
                   (get-text-property (point)
                                      :org-clock-force-headline-inclusion))
-- 
1.7.1.86.g0e460

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] clock reports: Only include current clocking task when range includes task
  2010-05-17  2:12   ` Bernt Hansen
@ 2010-05-17  9:36     ` Carsten Dominik
  2010-05-17 11:51       ` [PATCH] Fix clock report when not clocking an entry Bernt Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2010-05-17  9:36 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Applied, thanks.

- Carsten

On May 17, 2010, at 4:12 AM, Bernt Hansen wrote:

> When org-clock-report-include-clocking-task is set we always add the
> current clocking task to the clock report.  This is incorrect if you
> are looking at an agenda clock report for a time range that does not
> include the current clocking task (e.g. yesterday or last week).
>
> Now we only include the current clocking task if the clock report
> date range includes the current clocking task start time.
> ---
> Update patch without the debug call to the (message)
>
> This patch is available at git://git.norang.ca/org-mode.git for- 
> carsten
>
> -Bernt
>
> lisp/org-clock.el |   13 ++++++++-----
> 1 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 504f0c9..07e2e45 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -1396,12 +1396,15 @@ nil are excluded from the clock summation."
> 		      (* 60 (string-to-number (match-string 4))))))
> 	 (t ;; A headline
> 	  ;; Add the currently clocking item time to the total
> -	  (when (and org-clock-report-include-clocking-task
> -		     (equal (org-clocking-buffer) (current-buffer))
> -		     (equal (marker-position org-clock-hd-marker) (point)))
> +	  (let ((org-clock-start-time-as-float (org-float-time org-clock- 
> start-time)))
> +	    (when (and org-clock-report-include-clocking-task
> +		       (equal (org-clocking-buffer) (current-buffer))
> +		       (equal (marker-position org-clock-hd-marker) (point))
> +		       (>= org-clock-start-time-as-float tstart)
> +		       (<= org-clock-start-time-as-float tend))
> 	      (let ((time (floor (- (org-float-time)
> -				    (org-float-time org-clock-start-time)) 60)))
> -		(setq t1 (+ t1 time))))
> +				    org-clock-start-time-as-float) 60)))
> +		(setq t1 (+ t1 time)))))
> 	  (let* ((headline-forced
>                   (get-text-property (point)
>                                      :org-clock-force-headline- 
> inclusion))
> -- 
> 1.7.1.86.g0e460
>
>
> _______________________________________________
> 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] 6+ messages in thread

* [PATCH] Fix clock report when not clocking an entry
  2010-05-17  9:36     ` Carsten Dominik
@ 2010-05-17 11:51       ` Bernt Hansen
  2010-05-17 11:56         ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Bernt Hansen @ 2010-05-17 11:51 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

I tried to save a few calls to org-float-time but org-clock-start-time is not
valid as a parameter to org-float-time when it is an empty string (when you
are not clocking anything).

Verify tstart and tend are non-nil so we can compare them to the current clocking time
using <= and >=
---
 I need to test more :/

 I ran into two cases this morning where the clock report patch throws an error.
 Here's a fix for both.

 -Bernt

 lisp/org-clock.el |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 07e2e45..68a40ce 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1396,17 +1396,18 @@ nil are excluded from the clock summation."
 		      (* 60 (string-to-number (match-string 4))))))
 	 (t ;; A headline
 	  ;; Add the currently clocking item time to the total
-	  (let ((org-clock-start-time-as-float (org-float-time org-clock-start-time)))
-	    (when (and org-clock-report-include-clocking-task
-		       (equal (org-clocking-buffer) (current-buffer))
-		       (equal (marker-position org-clock-hd-marker) (point))
-		       (>= org-clock-start-time-as-float tstart)
-		       (<= org-clock-start-time-as-float tend))
-	      (let ((time (floor (- (org-float-time)
-				    org-clock-start-time-as-float) 60)))
-		(setq t1 (+ t1 time)))))
+	  (when (and org-clock-report-include-clocking-task
+		     (equal (org-clocking-buffer) (current-buffer))
+		     (equal (marker-position org-clock-hd-marker) (point))
+		     tstart
+		     tend
+		     (>= (org-float-time org-clock-start-time) tstart)
+		     (<= (org-float-time org-clock-start-time) tend))
+	    (let ((time (floor (- (org-float-time)
+				  (org-float-time org-clock-start-time)) 60)))
+	      (setq t1 (+ t1 time))))
 	  (let* ((headline-forced
-                  (get-text-property (point)
+		  (get-text-property (point)
                                      :org-clock-force-headline-inclusion))
                  (headline-included
                   (or (null headline-filter)
-- 
1.7.1.86.g0e460

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix clock report when not clocking an entry
  2010-05-17 11:51       ` [PATCH] Fix clock report when not clocking an entry Bernt Hansen
@ 2010-05-17 11:56         ` Carsten Dominik
  0 siblings, 0 replies; 6+ messages in thread
From: Carsten Dominik @ 2010-05-17 11:56 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Applied, thanks.

- Carsten

On May 17, 2010, at 1:51 PM, Bernt Hansen wrote:

> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index 07e2e45..68a40ce 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -1396,17 +1396,18 @@ nil are excluded from the clock summation."
>  		      (* 60 (string-to-number (match-string 4))))))
>  	 (t ;; A headline
>  	  ;; Add the currently clocking item time to the total
> -	  (let ((org-clock-start-time-as-float (org-float-time org-clock- 
> start-time)))
> -	    (when (and org-clock-report-include-clocking-task
> -		       (equal (org-clocking-buffer) (current-buffer))
> -		       (equal (marker-position org-clock-hd-marker) (point))
> -		       (>= org-clock-start-time-as-float tstart)
> -		       (<= org-clock-start-time-as-float tend))
> -	      (let ((time (floor (- (org-float-time)
> -				    org-clock-start-time-as-float) 60)))
> -		(setq t1 (+ t1 time)))))
> +	  (when (and org-clock-report-include-clocking-task
> +		     (equal (org-clocking-buffer) (current-buffer))
> +		     (equal (marker-position org-clock-hd-marker) (point))
> +		     tstart
> +		     tend
> +		     (>= (org-float-time org-clock-start-time) tstart)
> +		     (<= (org-float-time org-clock-start-time) tend))
> +	    (let ((time (floor (- (org-float-time)
> +				  (org-float-time org-clock-start-time)) 60)))
> +	      (setq t1 (+ t1 time))))
>  	  (let* ((headline-forced
> -                  (get-text-property (point)
> +		  (get-text-property (point)
>                                       :org-clock-force-headline- 
> inclusion))
>                   (headline-included
>                    (or (null headline-filter)

- Carsten

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-17 11:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-17  2:05 [PATCH] clock reports: Only include current clocking task when range includes task Bernt Hansen
2010-05-17  2:09 ` Bernt Hansen
2010-05-17  2:12   ` Bernt Hansen
2010-05-17  9:36     ` Carsten Dominik
2010-05-17 11:51       ` [PATCH] Fix clock report when not clocking an entry Bernt Hansen
2010-05-17 11:56         ` Carsten Dominik

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).