emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Achim Gratz <Stromeko@nexgo.de>
To: emacs-orgmode@gnu.org
Subject: Re: [BUG] hline references on left side of table formula
Date: Wed, 06 Nov 2013 20:57:29 +0100	[thread overview]
Message-ID: <87ob5xtiae.fsf@Rainer.invalid> (raw)
In-Reply-To: 39f042b047fcc17e87f5ceb8ebd3e038@mail.rickster.com

Rick Frankel writes:
> What he is saying, is that references like =@II$2=, or =@II+1$2= do not
> work correctly on the left-hand side of a table format (verified by
> carsten in a previous thread) which is why i created the patch to
> disallow hline-relative references on th LHS.

They are working, sort of, by constructing an LHS range implicitly with
the cursor at the end of the table in the first column (equivalent of
@$).  This is hard to explain, but try a slightly more advance table:

| a | b |
|---+---|
| w | 1 |
| x | 2 |
|---+---|
|   |   |
|   |   |
|---+---|
| y | 3 |
| z | 4 |
|---+---|
|   |   |

with these formulas:
#+TBLFM: $=vsum(@-II..@-I)


> However, he has found that ranged references line as =@II$2..@II+2$2=
> do in fact work to reference a single cell on the left hand side on a
> formula.
>
> For example:
>
> Given the input table:
>
> | a | b |
> |---+---|
> | x | 1 |
> | y | 2 |
> |---+---|
> |   |   |
> |   |   |
>
> The following results occur:
>
> | a     | b |
> |-------+---|
> | x     | 1 |
> | y     | 2 |
> |-------+---|
> | x + y | 3 |
> | x + y | 3 |
> #+TBLFM: @II$2=vsum(@I..@II)
>
> | a | b |
> |---+---|
> | x | 1 |
> | y | 2 |
> |---+---|
> |   | 3 |
> |   |   |
> #+TBLFM: @II$2..@II+1$2=vsum(@I..@II)
>
> | a | b |
> |---+---|
> | x | 1 |
> | y | 2 |
> |---+---|
> | 3 | 3 |
> | 3 | 3 |
> #+TBLFM: @II$2=vsum(@I$2..@II$2)
>
> | a | b |
> |---+---|
> | x | 1 |
> | y | 2 |
> |---+---|
> |   | 3 |
> |   |   |
> #+TBLFM: @II$2..@II+1$2=vsum(@I$2..@II$2)
>
> So, perhaps my patch was premature, but should instead should check
> for hline refs w/o ranges on the lhs. Here's a new patch to only
> error-out if there is no range spec. Note that this also fixes Achim's
> issue w/ the colnames test failing.
>
>
> rick
>
> -------------------- 8< --------------------
> --- a/lisp/org-table.el
> +++ b/lisp/org-table.el
> @@ -3016,8 +3016,9 @@ known that the table will be realigned a little 
> later anyway."
> ;; Insert constants in all formulas
> (setq eqlist
> (mapcar (lambda (x)
> -             (if (string-match "^@-?I+" (car x))
> -             (user-error "Can't assign to hline relative reference"))
> +             (if (and (string-match "^@-?I+" (car x))
> +                  (not (string-match "\.\.@" (car x))))
> +             (user-error "Can't assign to hline relative reference 
> without a range specification."))
> (when (string-match "\\`$[<>]" (car x))
> (setq lhs1 (car x))
> (setq x (cons (substring
>
>
>
>
-- 

Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

  reply	other threads:[~2013-11-06 19:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01  5:32 [BUG] hline references on left side of table formula lompik
2013-11-06  8:23 ` Bastien
2013-11-06 18:50   ` Rick Frankel
2013-11-06 19:57     ` Achim Gratz [this message]
2013-11-06 20:14       ` Achim Gratz
2013-11-07 15:01         ` Rick Frankel
2013-11-07 19:16           ` Achim Gratz
2013-11-07  5:59     ` Michael Brand
2013-11-07 14:40       ` Rick Frankel
  -- strict thread matches above, loose matches on Subject: below --
2013-05-01 17:27 Rick Frankel
2013-09-02  8:10 ` 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=87ob5xtiae.fsf@Rainer.invalid \
    --to=stromeko@nexgo.de \
    --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).