forked from mirrors/org-mode
org-clock: Fix number of time columns in clock table
* lisp/org-clock.el (org-clocktable-write-default): Limit number of time columns to the deepest headline level. * testing/lisp/test-org-clock.el (test-org-clock/clocktable/maxlevel): Update tests.
This commit is contained in:
parent
2d29269bb1
commit
75e9fdac6c
|
@ -2474,8 +2474,20 @@ from the dynamic block definition."
|
|||
(level? (and (not compact?) (plist-get params :level)))
|
||||
(timestamp (plist-get params :timestamp))
|
||||
(properties (plist-get params :properties))
|
||||
(time-columns (if compact? 1
|
||||
(min maxlevel (or (plist-get params :tcolumns) 100))))
|
||||
(time-columns
|
||||
(if (or compact? (< maxlevel 2)) 1
|
||||
;; Deepest headline level is a hard limit for the number
|
||||
;; of time columns.
|
||||
(let ((levels
|
||||
(cl-mapcan
|
||||
(lambda (table)
|
||||
(pcase table
|
||||
(`(,_ ,(and (pred wholenump) (pred (/= 0))) ,entries)
|
||||
(mapcar #'car entries))))
|
||||
tables)))
|
||||
(min maxlevel
|
||||
(or (plist-get params :tcolumns) 100)
|
||||
(if (null levels) 1 (apply #'max levels))))))
|
||||
(indent (or compact? (plist-get params :indent)))
|
||||
(formula (plist-get params :formula))
|
||||
(case-fold-search t)
|
||||
|
|
|
@ -370,12 +370,12 @@ CLOCK: [2012-03-29 Thu 16:40]--[2014-03-04 Thu 00:41] => 16905:01
|
|||
(ert-deftest test-org-clock/clocktable/maxlevel ()
|
||||
"Test \":maxlevel\" parameter in Clock table."
|
||||
(should
|
||||
(equal "| Headline | Time | | |
|
||||
|--------------+--------+------+---|
|
||||
| *Total time* | *6:00* | | |
|
||||
|--------------+--------+------+---|
|
||||
| Foo | 6:00 | | |
|
||||
| \\_ Bar | | 2:00 | |
|
||||
(equal "| Headline | Time | |
|
||||
|--------------+--------+------|
|
||||
| *Total time* | *6:00* | |
|
||||
|--------------+--------+------|
|
||||
| Foo | 6:00 | |
|
||||
| \\_ Bar | | 2:00 |
|
||||
"
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
|
|
Loading…
Reference in a new issue