From a6c318f471fdd607f6659b874a066f28affbbc98 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 18 Feb 2017 20:22:30 +0100 Subject: [PATCH] org-clock: Fix missing properties in Clock table * lisp/org-clock.el (org-clocktable-write-default): Do not ignore properties specified by :properties parameter. * testing/lisp/test-org-clock.el (test-org-clock/clocktable/properties): New test. The regression was introduced in b897ab722. Reported-by: Dale --- lisp/org-clock.el | 13 ++++---- testing/lisp/test-org-clock.el | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index d5aa8c170..a807e2c52 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2587,7 +2587,7 @@ from the dynamic block definition." ;; Get the list of node entries and iterate over it (when (> maxlevel 0) - (pcase-dolist (`(,level ,headline ,ts ,time . ,props) entries) + (pcase-dolist (`(,level ,headline ,ts ,time ,props) entries) (when narrow-cut-p (setq headline (if (and (string-match @@ -2599,12 +2599,11 @@ from the dynamic block definition." (org-shorten-string (match-string 3 headline) narrow)) (org-shorten-string headline narrow)))) - (cl-flet ((format-field - (let ((marker (pcase level - ((guard (not emph)) "") - (1 "*") (2 "/") (_ "")))) - (lambda (field) - (format "%s%s%s |" marker field marker))))) + (cl-flet ((format-field (f) (format (cond ((not emph) "%s |") + ((= level 1) "*%s* |") + ((= level 2) "/%s/ |") + (t "%s |")) + f))) (insert-before-markers "|" ;start the table line (if multifile "|" "") ;free space for file name column? diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el index 2f8ecf3a9..8d817e3b6 100644 --- a/testing/lisp/test-org-clock.el +++ b/testing/lisp/test-org-clock.el @@ -695,6 +695,61 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00 (buffer-substring-no-properties (line-beginning-position 3) (line-beginning-position 9)))))) +(ert-deftest test-org-clock/clocktable/properties () + "Test \":properties\" parameter in Clock table." + ;; Include a new column with list properties. + (should + (equal + "| A | Headline | Time | | +|---+--------------+---------+---| +| | *Total time* | *26:00* | | +|---+--------------+---------+---| +| 1 | Foo | 26:00 | | +" + (org-test-with-temp-text + "* Foo +:PROPERTIES: +:A: 1 +:END: +CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00 +" + (test-org-clock-clocktable-contents-at-point ":properties (\"A\")")))) + (should + (equal + "| A | Headline | Time | | +|---+--------------+---------+-------| +| | *Total time* | *52:00* | | +|---+--------------+---------+-------| +| | Foo | 52:00 | | +| 1 | \\_ Bar | | 26:00 | +" + (org-test-with-temp-text + "* Foo +CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00 +** Bar +:PROPERTIES: +:A: 1 +:END: +CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00 +" + (test-org-clock-clocktable-contents-at-point ":properties (\"A\")")))) + ;; Handle missing properties. + (should + (equal + "| A | Headline | Time | | +|---+--------------+---------+---| +| | *Total time* | *26:00* | | +|---+--------------+---------+---| +| 1 | Foo | 26:00 | | +" + (org-test-with-temp-text + "* Foo +:PROPERTIES: +:A: 1 +:END: +CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00 +" + (test-org-clock-clocktable-contents-at-point ":properties (\"A\")"))))) (provide 'test-org-clock) ;;; test-org-clock.el end here