diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2010-12-03 09:50:38 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2010-12-03 09:50:38 +0100 |
commit | 61b2247631e2bdf59894fa8727c51aa30fe9209e (patch) | |
tree | a0c290133a89aa11d78357d39921d96e590c6d40 | |
parent | 2ac751a6cb5db00167cd3b0d100b0dfa2ba048da (diff) | |
download | org-mode-61b2247631e2bdf59894fa8727c51aa30fe9209e.tar.gz |
Fix % formula in clock tables
* lisp/org-clock.el (org-clocktable-write-default): Fix the % formula.
Bug reported by Joost Helberg.
-rw-r--r-- | lisp/org-clock.el | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el index eb859df..c303ad5 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2165,18 +2165,25 @@ from the dynamic block defintion." (if (setq formula (plist-get params :formula)) (cond ((eq formula '%) - (setq pcol (+ 3 + ;; compute the column where the % numbers need to go + (setq pcol (+ 2 (if multifile 1 0) - (min maxlevel (or ntcol 100)) + (if level-p 1 0) + (if timestamp 1 0) + (min maxlevel (or ntcol 100)))) + ;; compute the column where the total time is + (setq tcol (+ 2 + (if multifile 1 0) + (if level-p 1 0) (if timestamp 1 0))) (insert (format "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f" - pcol - (+ 2 (if narrow 1 0)) - (+ 3 (if multifile 1 0)) - (+ (if multifile 1 0) 3) - (1- pcol))) + pcol ; the column where the % numbers should go + (if (and narrow (not narrow-cut-p)) 3 2) ; row of the total time + tcol ; column of the total time + tcol (1- pcol) ; range of columns where times can be found + )) (setq recalc t)) ((stringp formula) (insert "\n#+TBLFM: " formula) @@ -2198,7 +2205,7 @@ from the dynamic block defintion." (when recalc (if (eq formula '%) (save-excursion - (if narrow (beginning-of-line 2)) + (if (and narrow (not narrow-cut-p)) (beginning-of-line 2)) (org-table-goto-column pcol nil 'force) (insert "%"))) (org-table-recalculate 'all)) |