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
This commit is contained in:
Eduardo Bellani 2017-03-06 17:57:31 +01:00 committed by Nicolas Goaziou
parent e7a52eeaa4
commit 78bddaca1f
4 changed files with 18 additions and 2 deletions

View File

@ -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}

View File

@ -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~

View File

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

View File

@ -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."