Browse Source

Allow to skip steps in clock reports that have zero time

* org-clock.el (org-dblock-write:clocktable): Return total time.
(org-clocktable-steps): Skip step when time is zero and the
:stepskip0 property is set.

Rainer Stengele writes:

> Creating clocktables for each day of a month is an excellent feature
> in org!  Problem for me is that many resulting tables have a total
> time of 0:00.  The problem is not really the zero time I spent but the
> appearance of the tables with zero total time.
>
> Is there a possibility to skip getting such tables?  Rational: I do
> not need to show my boss or customer days where I spent 0:00 time on
> the project.

Now you can set :stepskip0 to achieve this.
Carsten Dominik 15 years ago
parent
commit
5b68cf4c4f
2 changed files with 12 additions and 3 deletions
  1. 1 0
      doc/org.texi
  2. 11 3
      lisp/org-clock.el

+ 1 - 0
doc/org.texi

@@ -5607,6 +5607,7 @@ new table.  The @samp{BEGIN} line can specify options:
 :tend        @r{A time string specifying when to stop considering times.}
 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
+:stepskip0   @r{Don't show steps that have zero time}
 :tags        @r{A tags match to select entries that should contribute}
 :link        @r{Link the item headlines in the table to their origins.}
 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}

+ 11 - 3
lisp/org-clock.el

@@ -1948,7 +1948,8 @@ the currently selected interval size."
 	    (org-table-recalculate 'all))
 	  (when rm-file-column
 	    (forward-char 1)
-	    (org-table-delete-column)))))))
+	    (org-table-delete-column))
+	  total-time)))))
 
 (defun org-clocktable-steps (params)
   (let* ((p1 (copy-sequence params))
@@ -1956,8 +1957,9 @@ the currently selected interval size."
 	 (te (plist-get p1 :tend))
 	 (step0 (plist-get p1 :step))
 	 (step (cdr (assoc step0 '((day . 86400) (week . 604800)))))
+	 (stepskip0 (plist-get p1 :stepskip0))
 	 (block (plist-get p1 :block))
-	 cc range-text)
+	 cc range-text step-time)
     (when block
       (setq cc (org-clock-special-range block nil t)
 	    ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
@@ -1978,8 +1980,14 @@ the currently selected interval size."
 				    (seconds-to-time (setq ts (+ ts step))))))
       (insert "\n" (if (eq step0 'day) "Daily report: " "Weekly report starting on: ")
 	      (plist-get p1 :tstart) "\n")
-      (org-dblock-write:clocktable p1)
+      (setq step-time (org-dblock-write:clocktable p1))
       (re-search-forward "#\\+END:")
+      (when (and (equal step-time 0) stepskip0)
+	;; Remove the empty table
+	(delete-region (point-at-bol)
+		       (save-excursion
+			 (re-search-backward "^\\(Daily\\|Weekly\\) report" nil t)
+			 (point))))
       (end-of-line 0))))
 
 (defun org-clocktable-add-file (file table)