all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Rares Vernica <rvernica@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
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	[thread overview]
Message-ID: <CALn3zoh7wnQnpxbNLF_Kj1NeaCeKckOXMhmj_HoD_bsjULvYbg@mail.gmail.com> (raw)
In-Reply-To: <87vb0gbwnx.fsf@gmail.com>

Hi Rares

On Fri, Jul 8, 2016 at 6:06 AM, Rares Vernica <rvernica@gmail.com> 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

      reply	other threads:[~2016-07-10 14:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 16:28 Bug: Table formula does not copy time interval correctly [8.2.10 (release_8.2.10 @ /usr/share/emacs/25.0.94/lisp/org/)] Rares Vernica
2016-07-07  6:52 ` Michael Brand
2016-07-08  4:06   ` Rares Vernica
2016-07-10 14:38     ` Michael Brand [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALn3zoh7wnQnpxbNLF_Kj1NeaCeKckOXMhmj_HoD_bsjULvYbg@mail.gmail.com \
    --to=michael.ch.brand@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=rvernica@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.