From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mikael Fornius Subject: Re: colview min/mean/max Date: Thu, 21 May 2009 09:23:24 +0200 Message-ID: <877i0aj4wj.fsf@abc.se> References: <87ab58owii.fsf@abc.se> <87ws8boqoy.fsf@abc.se> <87fxeziefz.fsf@abc.se> <8C863AC3-D6AB-4F2A-B52E-DF536F400F19@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M72cp-0001RP-Ve for emacs-orgmode@gnu.org; Thu, 21 May 2009 03:23:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M72ck-0001RB-FS for emacs-orgmode@gnu.org; Thu, 21 May 2009 03:23:34 -0400 Received: from [199.232.76.173] (port=59566 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M72ck-0001R8-9A for emacs-orgmode@gnu.org; Thu, 21 May 2009 03:23:30 -0400 Received: from mx20.gnu.org ([199.232.41.8]:33361) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M72cj-0002cw-Rw for emacs-orgmode@gnu.org; Thu, 21 May 2009 03:23:30 -0400 Received: from violet.abc.se ([62.80.200.155]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M72cj-00065v-0P for emacs-orgmode@gnu.org; Thu, 21 May 2009 03:23:29 -0400 In-Reply-To: <8C863AC3-D6AB-4F2A-B52E-DF536F400F19@gmail.com> (Carsten Dominik's message of "Thu, 21 May 2009 08:01:19 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Carsten Dominik Cc: emacs-orgmode@gnu.org --=-=-= Carsten Dominik 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=fix-empty-properties.patch 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))) --=-=-= -- Mikael Fornius --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-=-=--