[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [BUG] hline references on left side of table formula
From: |
Achim Gratz |
Subject: |
Re: [O] [BUG] hline references on left side of table formula |
Date: |
Wed, 06 Nov 2013 20:57:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Rick Frankel writes:
> What he is saying, is that references like address@hidden, or address@hidden
> 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(@address@hidden)
> However, he has found that ranged references line as address@hidden@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(@address@hidden)
>
> | a | b |
> |---+---|
> | x | 1 |
> | y | 2 |
> |---+---|
> | | 3 |
> | | |
> #+TBLFM: @address@hidden(@address@hidden)
>
> | a | b |
> |---+---|
> | x | 1 |
> | y | 2 |
> |---+---|
> | 3 | 3 |
> | 3 | 3 |
> #+TBLFM: @II$2=vsum(@address@hidden)
>
> | a | b |
> |---+---|
> | x | 1 |
> | y | 2 |
> |---+---|
> | | 3 |
> | | |
> #+TBLFM: @address@hidden(@address@hidden)
>
> 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 "address@hidden" (car x))
> - (user-error "Can't assign to hline relative reference"))
> + (if (and (string-match "address@hidden" (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