From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: Bug: Table formula does not copy time interval correctly [8.2.10 (release_8.2.10 @ /usr/share/emacs/25.0.94/lisp/org/)] Date: Sun, 10 Jul 2016 16:38:54 +0200 Message-ID: References: <87vb0gbwnx.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMFsp-0000Mt-Cd for emacs-orgmode@gnu.org; Sun, 10 Jul 2016 10:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMFsn-00072G-Gi for emacs-orgmode@gnu.org; Sun, 10 Jul 2016 10:38:58 -0400 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:38893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMFsn-00072C-9A for emacs-orgmode@gnu.org; Sun, 10 Jul 2016 10:38:57 -0400 Received: by mail-wm0-x22b.google.com with SMTP id o80so20851021wme.1 for ; Sun, 10 Jul 2016 07:38:56 -0700 (PDT) In-Reply-To: <87vb0gbwnx.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Rares Vernica Cc: Org Mode Hi Rares On Fri, Jul 8, 2016 at 6:06 AM, Rares Vernica wrote: > Just to clarify, how would you fix this: > > | [2016-07-05 Tue]--[2016-07-06 Wed] | 1d | vsum(d) | > | [2016-07-06 Wed]--[2016-07-07 Thu] | 1d | 2 d | > #+TBLFM: $3=vsum(@1$-1..@0$-1) > > Notice the "vsum(d)" instead of the expected "1 d". Depending on the number of fields in a range Org builds just a value or a Calc vector of values. This is due to the comparison of r1/r2 and c1/c2 which are the row and column beginning and end of the range in the function org-table-get-range: (if (and (not corners-only) (or (not rangep) (and (= r1 r2) (= c1 c2)))) ;; Just one field. [...] ;; A range, return a vector. [...]) I can not think of any use case where this should be more useful than substituting ~(and (= r1 r2) (= c1 c2))~ with ~nil~. But since this substitution could break existing usage I suggest to add ~vec~ to the Calc formula: | [2016-07-05 Tue]--[2016-07-06 Wed] | 1d | d | [d] | d | | [2016-07-06 Wed]--[2016-07-07 Thu] | 1d | [d, d] | [[d, d]] | 2 d | #+TBLFM: $3 = @1$2..@0$2 :: $4 = vec(@1$2..@0$2) :: $5 = vsum(vec(@1$2..@0$2)) Michael