From: Mikael Fornius <mfo@abc.se>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: colview min/mean/max
Date: Thu, 21 May 2009 09:23:24 +0200 [thread overview]
Message-ID: <877i0aj4wj.fsf@abc.se> (raw)
In-Reply-To: <8C863AC3-D6AB-4F2A-B52E-DF536F400F19@gmail.com> (Carsten Dominik's message of "Thu, 21 May 2009 08:01:19 +0200")
[-- Attachment #1: Type: text/plain, Size: 599 bytes --]
Carsten Dominik <carsten.dominik@gmail.com> writes:
> I have applied this patch, thank you for your contribution!
My pleasure.
> No hurry, better to get it complete and tested...
> :-)
I should have read this advice more carefully :-)
Because before, when only sums where calculated as summaries, 0 was
placed instead of empty or non numeric properties.
This makes calcualtions wrong with min/mean/max operators.
I only use complete tables so I did not notice this before now.
So I have changed this behavior to ignore empty properties and also
hanlde cases when all properties are wrong.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-empty-properties.patch --]
[-- Type: text/x-patch, Size: 3106 bytes --]
diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el
index 5986d43..c63d906 100644
--- a/lisp/org-colview-xemacs.el
+++ b/lisp/org-colview-xemacs.el
@@ -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)))
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 5e2810f..cd9ea2b 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -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)))
[-- Attachment #3: Type: text/plain, Size: 21 bytes --]
--
Mikael Fornius
[-- Attachment #4: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2009-05-21 7:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 11:15 colview min/mean/max Mikael Fornius
2009-05-20 13:21 ` Mikael Fornius
2009-05-20 13:47 ` Carsten Dominik
2009-05-20 22:42 ` Mikael Fornius
2009-05-21 6:01 ` Carsten Dominik
2009-05-21 7:23 ` Mikael Fornius [this message]
2009-05-21 8:48 ` Carsten Dominik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877i0aj4wj.fsf@abc.se \
--to=mfo@abc.se \
--cc=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).