emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Optionally include current clocking task time in clock reports
@ 2010-02-27  2:09 Bernt Hansen
  2010-03-01 10:57 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Bernt Hansen @ 2010-02-27  2:09 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

Use a new custom variable org-clock-report-include-clocking-task which defaults
to nil to keep the original clock reporting behaviour.
---
This patch is available at git://git.norang.ca/org-mode for-carsten

 lisp/org-clock.el |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index cb378e6..0244f31 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -240,6 +240,11 @@ string as argument."
 	  (const :tag "Always" t)
 	  (const :tag "When no clock is running" when-no-clock-is-running)))
 
+(defcustom org-clock-report-include-clocking-task nil
+  "When non-nil, include the current clocking task time in clock reports."
+  :group 'org-clock
+  :type 'boolean)
+
 (defvar org-clock-in-prepare-hook nil
   "Hook run when preparing the clock.
 This hook is run before anything happens to the task that
@@ -1341,6 +1346,13 @@ TSTART and TEND can mark a time range to be considered."
 	  (setq t1 (+ t1 (string-to-number (match-string 5))
 		      (* 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 ((time (floor (- (org-float-time)
+				    (org-float-time org-clock-start-time)) 60)))
+		(setq t1 (+ t1 time))))
 	  (setq level (- (match-end 1) (match-beginning 1)))
 	  (when (or (> t1 0) (> (aref ltimes level) 0))
 	    (loop for l from 0 to level do
-- 
1.7.0.90.g251a4

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

* Re: [PATCH] Optionally include current clocking task time in clock reports
  2010-02-27  2:09 [PATCH] Optionally include current clocking task time in clock reports Bernt Hansen
@ 2010-03-01 10:57 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2010-03-01 10:57 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Really, was it so simple in the end?

Thanks, I applied the patch.

- Carsten

On Feb 27, 2010, at 3:09 AM, Bernt Hansen wrote:

> Use a new custom variable org-clock-report-include-clocking-task  
> which defaults
> to nil to keep the original clock reporting behaviour.
> ---
> This patch is available at git://git.norang.ca/org-mode for-carsten
>
> lisp/org-clock.el |   12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/lisp/org-clock.el b/lisp/org-clock.el
> index cb378e6..0244f31 100644
> --- a/lisp/org-clock.el
> +++ b/lisp/org-clock.el
> @@ -240,6 +240,11 @@ string as argument."
> 	  (const :tag "Always" t)
> 	  (const :tag "When no clock is running" when-no-clock-is-running)))
>
> +(defcustom org-clock-report-include-clocking-task nil
> +  "When non-nil, include the current clocking task time in clock  
> reports."
> +  :group 'org-clock
> +  :type 'boolean)
> +
> (defvar org-clock-in-prepare-hook nil
>   "Hook run when preparing the clock.
> This hook is run before anything happens to the task that
> @@ -1341,6 +1346,13 @@ TSTART and TEND can mark a time range to be  
> considered."
> 	  (setq t1 (+ t1 (string-to-number (match-string 5))
> 		      (* 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 ((time (floor (- (org-float-time)
> +				    (org-float-time org-clock-start-time)) 60)))
> +		(setq t1 (+ t1 time))))
> 	  (setq level (- (match-end 1) (match-beginning 1)))
> 	  (when (or (> t1 0) (> (aref ltimes level) 0))
> 	    (loop for l from 0 to level do
> -- 
> 1.7.0.90.g251a4
>
>
>
> _______________________________________________
> 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] 2+ messages in thread

end of thread, other threads:[~2010-03-01 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-27  2:09 [PATCH] Optionally include current clocking task time in clock reports Bernt Hansen
2010-03-01 10:57 ` 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).