Ver código fonte

org-clock.el: Add nullary function evaluation as a clocktable scope parameter

* lisp/org-clock.el (org-dblock-write:clocktable): Funcall the scope
  argument if it is a function.

* doc/org.texi: Document the feature of using a nullary function as the
  scope for the clocktable.

* testing/lisp/test-org-clock.el: Adds a test for the above
  feature.  Also, fix the number of hours of a test that seemed to be
  broken.

TINYCHANGE
Eduardo Bellani 8 anos atrás
pai
commit
78bddaca1f
4 arquivos alterados com 18 adições e 2 exclusões
  1. 1 0
      doc/org.texi
  2. 3 0
      etc/ORG-NEWS
  3. 1 0
      lisp/org-clock.el
  4. 13 2
      testing/lisp/test-org-clock.el

+ 1 - 0
doc/org.texi

@@ -6635,6 +6635,7 @@ be selected:
              tree       @r{the surrounding level 1 tree}
              agenda     @r{all agenda files}
              ("file"..) @r{scan these files}
+             function   @r{the list of files returned by a function of no argument}
              file-with-archives    @r{current file and its archives}
              agenda-with-archives  @r{all agenda files, including archives}
 :block       @r{The time block to consider.  This block is specified either}

+ 3 - 0
etc/ORG-NEWS

@@ -159,6 +159,9 @@ Select * From Users
 Where clue > 0
 ,#+END_SRC
 #+end_example
+*** New ~function~ scope argument for the Clock Table
+Added a nullary function that returns a list of files as a possible
+argument for the scope of the clock table.
 *** Export
 **** Add Slovanian translations
 **** Implement ~org-export-insert-image-links~

+ 1 - 0
lisp/org-clock.el

@@ -2378,6 +2378,7 @@ the currently selected interval size."
 		    (`file-with-archives
 		     (and buffer-file-name
 			  (org-add-archive-files (list buffer-file-name))))
+		    ((pred functionp) (funcall scope))
 		    ((pred consp) scope)
 		    (_ (or (buffer-file-name) (current-buffer)))))
 	   (block (plist-get params :block))

+ 13 - 2
testing/lisp/test-org-clock.el

@@ -351,9 +351,20 @@ the buffer."
 #+TBLFM: $3=string(\"foo\")"
     (org-test-with-temp-text-in-file
         "* Test
-CLOCK: [2012-03-29 Thu 16:40]--[2014-03-04 Thu 00:41] => 16905:01"
+CLOCK: [2012-03-29 Thu 16:40]--[2014-03-04 Thu 01:41] => 16905:01"
       (test-org-clock-clocktable-contents ":scope file-with-archives"
-	  "#+TBLFM: $3=string(\"foo\")")))))
+	  "#+TBLFM: $3=string(\"foo\")"))))
+  ;; Test "function" scope.
+  (should
+   (string-match-p
+    (regexp-quote "| ALL *Total time* | *1:00* |")
+    (org-test-with-temp-text-in-file
+	"* Test
+CLOCK: [2012-03-29 Thu 16:00]--[2012-03-29 Thu 17:00] =>  1:00"
+      (let ((the-file (buffer-file-name)))
+	(org-test-with-temp-text-in-file ""
+	  (test-org-clock-clocktable-contents
+	      (format ":scope (lambda () (list %S))" the-file))))))))
 
 (ert-deftest test-org-clock/clocktable/maxlevel ()
   "Test \":maxlevel\" parameter in Clock table."