1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-25 10:47:12 +00:00

Column View: Handle empty fields when computing

This commit is contained in:
Carsten Dominik 2009-05-21 10:47:56 +02:00
parent 91f77d7029
commit f49cee2cc4
3 changed files with 18 additions and 6 deletions

View File

@ -1,5 +1,11 @@
2009-05-21 Carsten Dominik <carsten.dominik@gmail.com>
* org-colview-xemacs.el (org-columns-compute)
(org-columns-number-to-string): Fix problems with empty fields.
* org-colview.el (org-columns-compute)
(org-columns-number-to-string): Fix problems with empty fields.
* org-exp.el (org-export-push-to-kill-ring): New function.
(org-export-copy-to-kill-ring): New option.

View File

@ -1097,7 +1097,8 @@ Don't set this, this is meant for dynamic scoping.")
(cond
((< level last-level)
;; put the sum of lower levels here as a property
(setq sum (apply fun (aref lvals last-level))
(setq sum (when (aref lvals last-level)
(apply fun (aref lvals last-level)))
flag (aref lflag last-level) ; any valid entries from children?
str (org-columns-number-to-string sum format printf)
str1 (org-add-props (copy-sequence str) nil 'org-computed t 'face 'bold)
@ -1123,9 +1124,10 @@ Don't set this, this is meant for dynamic scoping.")
(aset lflag l nil)))
((>= level last-level)
;; add what we have here to the accumulator for this level
(push (org-column-string-to-number (or val "0") format)
(when valflag
(push (org-column-string-to-number val format)
(aref lvals level))
(and valflag (aset lflag level t)))
(aset lflag level t)))
(t (error "This should not happen")))))))
(defun org-columns-redo ()
@ -1163,6 +1165,7 @@ Don't set this, this is meant for dynamic scoping.")
(defun org-columns-number-to-string (n fmt &optional printf)
"Convert a computed column number to a string value, according to FMT."
(cond
((not (numberp n)) "")
((memq fmt '(add_times max_times min_times mean_times))
(let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
(format org-time-clocksum-format h m)))

View File

@ -910,7 +910,8 @@ Don't set this, this is meant for dynamic scoping.")
(cond
((< level last-level)
;; put the sum of lower levels here as a property
(setq sum (apply fun (aref lvals last-level))
(setq sum (when (aref lvals last-level)
(apply fun (aref lvals last-level)))
flag (aref lflag last-level) ; any valid entries from children?
str (org-columns-number-to-string sum format printf)
str1 (org-add-props (copy-sequence str) nil 'org-computed t 'face 'bold)
@ -936,9 +937,10 @@ Don't set this, this is meant for dynamic scoping.")
(aset lflag l nil)))
((>= level last-level)
;; add what we have here to the accumulator for this level
(push (org-column-string-to-number (or val "0") format)
(when valflag
(push (org-column-string-to-number val format)
(aref lvals level))
(and valflag (aset lflag level t)))
(aset lflag level t)))
(t (error "This should not happen")))))))
(defun org-columns-redo ()
@ -976,6 +978,7 @@ Don't set this, this is meant for dynamic scoping.")
(defun org-columns-number-to-string (n fmt &optional printf)
"Convert a computed column number to a string value, according to FMT."
(cond
((not (numberp n)) "")
((memq fmt '(add_times max_times min_times mean_times))
(let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
(format org-time-clocksum-format h m)))