From 61b2247631e2bdf59894fa8727c51aa30fe9209e Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 3 Dec 2010 09:50:38 +0100 Subject: [PATCH] Fix % formula in clock tables * lisp/org-clock.el (org-clocktable-write-default): Fix the % formula. Bug reported by Joost Helberg. --- lisp/org-clock.el | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index eb859df5a..c303ad553 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)) -- 2.11.4.GIT