From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eduardo Bellani Subject: [PATCH] Add function evaluation parameter for the clocktable scope Date: Sun, 05 Mar 2017 22:01:49 -0300 Message-ID: <8737errzfe.fsf@brickabode.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckh2O-000467-MQ for emacs-orgmode@gnu.org; Sun, 05 Mar 2017 20:02:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ckh2L-0006Sn-Kv for emacs-orgmode@gnu.org; Sun, 05 Mar 2017 20:02:08 -0500 Received: from mail-ua0-x22c.google.com ([2607:f8b0:400c:c08::22c]:35785) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ckh2L-0006S7-Fo for emacs-orgmode@gnu.org; Sun, 05 Mar 2017 20:02:05 -0500 Received: by mail-ua0-x22c.google.com with SMTP id q7so116913934uaf.2 for ; Sun, 05 Mar 2017 17:02:03 -0800 (PST) Received: from personal ([191.191.76.25]) by smtp.gmail.com with ESMTPSA id x31sm4597367uax.9.2017.03.05.17.02.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Mar 2017 17:02:02 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: org mode 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. * etc/ORG-NEWS: Add a blurb declaring the new clocktable feature. This modifies the behavior of the scope parameter to have as scope a nullary function that returns a list of file paths. --- --- doc/org.texi | 1 + etc/ORG-NEWS | 6 +++++- lisp/org-clock.el | 3 ++- testing/lisp/test-org-clock.el | 27 +++++++++++++++++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 6be76d8..a8fbd8f 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -6638,6 +6638,7 @@ be selected: tree @r{the surrounding level 1 tree} agenda @r{all agenda files} ("file"..) @r{scan these files} + nullary function @r{scan the list of files returned by calling this nullary function.} 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} diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index c115cf9..6425a51 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -27,6 +27,10 @@ into *** Agenda **** New variable : ~org-agenda-show-future-repeats~ **** New variable : ~org-agenda-prefer-last-repeat~ +*** Clock table +**** New scope argument + Added a nullary function that returns a list of files as a + possible argument for the scope of the clock table. *** Babel **** Clojure: new setting ~org-babel-clojure-sync-nrepl-timeout~ diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 65c13fd..1e78188 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2370,7 +2370,8 @@ the currently selected interval size." (`file-with-archives (and buffer-file-name (org-add-archive-files (list buffer-file-name)))) - ((pred consp) scope) + ((pred functionp) (funcall scope)) + ((pred consp) scope) (_ (or (buffer-file-name) (current-buffer))))) (block (plist-get params :block)) (ts (plist-get params :tstart)) diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index f99affc..492fc39 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -347,7 +347,7 @@ contents. The clocktable doesn't appear in the buffer." " (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 #+BEGIN: clocktable :scope file-with-archives #+TBLFM: $3=string(\"foo\") @@ -359,7 +359,30 @@ CLOCK: [2012-03-29 Thu 16:40]--[2014-03-04 Thu 00:41] => 16905:01 (forward-line 2) (buffer-substring-no-properties (point) (progn (goto-char (point-max)) - (line-beginning-position -1))))))) + (line-beginning-position -1)))))) + ;; test scope using a function + (should + (equal + "| File | Headline | Time | +|-----------------+------------------+--------| +| | 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 + (format "#+BEGIN: clocktable :scope (lambda () (list %S)) +#+END:" the-file) + (search-forward "#+begin:") + (beginning-of-line) + (org-update-dblock) + (forward-line 2) + (buffer-substring-no-properties + (point) + (progn (goto-char (point-max)) + (line-beginning-position -1))))))))) (provide 'test-org-clock) ;;; test-org-clock.el end here -- TINYCHANGE