>> On Tue, 13 Mar 2012 12:00:07 +0000, Myles English said:
> 1. start with emacs -q
> 2. find file test-sums.org (attached)
> 3. adjust paths in the source block at the top of the file and evaluate
> (execute?) it with C-c
> 4. goto the columnview block and C-c
> I would expect a table like this to be inserted:
> | ITEM | Sum |
> |---------------------------------------------+------|
> | * Introduction | 5:40 |
> |---------------------------------------------+------|
> | ** test sums | 0:30 |
> |---------------------------------------------+------|
> | ** Getting warmed up | 5:10 |
> |---------------------------------------------+------|
> | *** Nitty gritty | 5:10 |
> | *************** TODO Do something fantastic | 5:00 |
> | *************** END | |
> |---------------------------------------------+------|
> | **** This is not added | 0:10 |
> | *************** TODO Do something else | 0:10 |
> | *************** END | |
> Hoever, the table looks like this:
> | ITEM | Sum |
> |---------------------------------------------+------|
> | * Introduction | 5:30 |
> |---------------------------------------------+------|
> | ** test sums | 0:30 |
> |---------------------------------------------+------|
> | ** Getting warmed up | 5:00 |
> |---------------------------------------------+------|
> | *** Nitty gritty | 5:00 |
> | *************** TODO Do something fantastic | 5:00 |
> | *************** END | |
> |---------------------------------------------+------|
> | **** This is not added | 0:10 |
> | *************** TODO Do something else | 0:10 |
> | *************** END | |
> i.e. the 0:10 is not being picked up in the accumulation.
The attached patch produces the expected output, for the same test file:
I am an elisp novice so please would someone check this before I tag it
as a [PATCH]. In particular, something I am not sure about is the
"(require 'org-inlinetask)" which obviously introduces a dependency.
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 04d2b62..5645ed3 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -931,6 +931,7 @@ Don't set this, this is meant for dynamic scoping.")
(defun org-columns-compute (property)
"Sum the values of property PROPERTY hierarchically, for the entire buffer."
(interactive)
+ (require 'org-inlinetask)
(let* ((re org-outline-regexp-bol)
(lmax 30) ; Does anyone use deeper levels???
(lvals (make-vector lmax nil))
@@ -942,7 +943,8 @@ Don't set this, this is meant for dynamic scoping.")
(fun (nth 6 ass))
(calc (or (nth 7 ass) 'identity))
(beg org-columns-top-level-marker)
- last-level val valflag flag end sumpos sum-alist sum str str1 useval)
+ (last-level org-inlinetask-min-level)
+ val valflag flag end sumpos sum-alist sum str str1 useval)
(save-excursion
;; Find the region to compute
(goto-char beg)
@@ -951,16 +953,24 @@ Don't set this, this is meant for dynamic scoping.")
;; Walk the tree from the back and do the computations
(while (re-search-backward re beg t)
(setq sumpos (match-beginning 0)
- last-level level
+ last-level (if (and (not (equal level 0) )
+ (not (equal level org-inlinetask-min-level)))
+ level last-level)
level (org-outline-level)
val (org-entry-get nil property)
valflag (and val (string-match "\\S-" val)))
(cond
((< level last-level)
;; put the sum of lower levels here as a property
- (setq sum (when (aref lvals last-level)
+ (setq sum (when (and
+ (not (equal last-level org-inlinetask-min-level))
+ (aref lvals last-level))
(apply fun (aref lvals last-level)))
- flag (aref lflag last-level) ; any valid entries from children?
+ sum2 (when (aref lvals org-inlinetask-min-level)
+ (apply fun (aref lvals org-inlinetask-min-level)))
+ sum (+ (or sum 0) (or sum2 0))
+ flag (or (aref lflag last-level) ; any valid entries from
children?
+ (aref lflag org-inlinetask-min-level)) ; or inline
tasks?
str (org-columns-number-to-string sum format printf)
str1 (org-add-props (copy-sequence str) nil 'org-computed t
'face 'bold)
useval (if flag str1 (if valflag val ""))
Thanks,
Myles