emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] hline references on left side of table formula
@ 2013-05-01 17:27 Rick Frankel
  2013-09-02  8:10 ` Carsten Dominik
  0 siblings, 1 reply; 9+ messages in thread
From: Rick Frankel @ 2013-05-01 17:27 UTC (permalink / raw)
  To: Org-Mode

Hi-

I don't know if this is a bug or feature :), but if an hline reference
(@I, etc) is used on the left side of a calculation, it applies to ALL
columns in the row even if the column is specfied.

Here are some examples to show the results. I would expect all three
versions to generate the same results as the first example.

#+BEGIN_ORG
   * Absolute reference (expected results)
     | a | b |
     |---+---|
     | x | 1 |
     | y | 2 |
     |---+---|
     |   | 3 |
   #+TBLFM: @4$2=vsum(@I..@II)

   * hline reference
     | a     | b |
     |-------+---|
     | x     | 1 |
     | y     | 2 |
     |-------+---|
     | x + y | 3 |
   #+TBLFM: @II$2=vsum(@I..@II)

   * hline reference with full cell specification in sum
     | a | b |
     |---+---|
     | x | 1 |
     | y | 2 |
     |---+---|
     | 3 | 3 |
   #+TBLFM: @II$2=vsum(@I$2..@II$2)
   #+END_ORG

FWIW, I believe the problem is that `org-table-recalculate' is
matching lhs cell references explicitly against pure numeric
references ("@[0-9]+$[0-9]+") and therefore expands the lhs via
`org-expand-lhs-ranges' instead of expanding it with
`org-table-get-descriptor-line'

rick

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] hline references on left side of table formula
  2013-05-01 17:27 [BUG] hline references on left side of table formula Rick Frankel
@ 2013-09-02  8:10 ` Carsten Dominik
  2013-09-25 17:57   ` [PATCH] Add check for assignment to hline relative references in table formulas Rick Frankel
  0 siblings, 1 reply; 9+ messages in thread
From: Carsten Dominik @ 2013-09-02  8:10 UTC (permalink / raw)
  To: Rick Frankel; +Cc: Org-Mode

Hi Rick,

hline-relative references on the left side of a table are currently not supported.  The fact that this is expanded is a bug.  A patch catching this case would be very welcome.

Regards

- Carsten

On May 1, 2013, at 7:27 PM, Rick Frankel <rick@rickster.com> wrote:

> Hi-
> 
> I don't know if this is a bug or feature :), but if an hline reference
> (@I, etc) is used on the left side of a calculation, it applies to ALL
> columns in the row even if the column is specfied.
> 
> Here are some examples to show the results. I would expect all three
> versions to generate the same results as the first example.
> 
> #+BEGIN_ORG
>  * Absolute reference (expected results)
>    | a | b |
>    |---+---|
>    | x | 1 |
>    | y | 2 |
>    |---+---|
>    |   | 3 |
>  #+TBLFM: @4$2=vsum(@I..@II)
> 
>  * hline reference
>    | a     | b |
>    |-------+---|
>    | x     | 1 |
>    | y     | 2 |
>    |-------+---|
>    | x + y | 3 |
>  #+TBLFM: @II$2=vsum(@I..@II)
> 
>  * hline reference with full cell specification in sum
>    | a | b |
>    |---+---|
>    | x | 1 |
>    | y | 2 |
>    |---+---|
>    | 3 | 3 |
>  #+TBLFM: @II$2=vsum(@I$2..@II$2)
>  #+END_ORG
> 
> FWIW, I believe the problem is that `org-table-recalculate' is
> matching lhs cell references explicitly against pure numeric
> references ("@[0-9]+$[0-9]+") and therefore expands the lhs via
> `org-expand-lhs-ranges' instead of expanding it with
> `org-table-get-descriptor-line'
> 
> rick
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] Add check for assignment to hline relative references in table formulas.
  2013-09-02  8:10 ` Carsten Dominik
@ 2013-09-25 17:57   ` Rick Frankel
  2013-11-05 11:08     ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Rick Frankel @ 2013-09-25 17:57 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-Mode

* org-table.el (org-table-recalculate): Generate user error if
an hline relative reference is use on the LHS of a formula.
---
lisp/org-table.el | 2 ++
1 file changed, 2 insertions(+)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 246cf8d..a3197d3 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3001,6 +3001,8 @@ 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"))
		      (when (string-match "\\`$[<>]" (car x))
			(setq lhs1 (car x))
			(setq x (cons (substring
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add check for assignment to hline relative references in table formulas.
  2013-09-25 17:57   ` [PATCH] Add check for assignment to hline relative references in table formulas Rick Frankel
@ 2013-11-05 11:08     ` Bastien
  2013-11-05 20:19       ` Achim Gratz
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2013-11-05 11:08 UTC (permalink / raw)
  To: Rick Frankel; +Cc: Org-Mode, Carsten Dominik

Hi Rick,

Rick Frankel <rick@rickster.com> writes:

> * org-table.el (org-table-recalculate): Generate user error if
> an hline relative reference is use on the LHS of a formula.

Applied, thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add check for assignment to hline relative references in table formulas.
  2013-11-05 11:08     ` Bastien
@ 2013-11-05 20:19       ` Achim Gratz
  2013-11-05 20:55         ` Bastien
  2013-11-07 19:37         ` Achim Gratz
  0 siblings, 2 replies; 9+ messages in thread
From: Achim Gratz @ 2013-11-05 20:19 UTC (permalink / raw)
  To: emacs-orgmode

Bastien writes:
>> * org-table.el (org-table-recalculate): Generate user error if
>> an hline relative reference is use on the LHS of a formula.
>
> Applied, thanks!

Rick is listed as a contributor, so the TINYCHANGE marker is wrong.

Besides, that change breaks test-org-table/compare, which for whatever
reason uses just such a LHS construct.


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

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add check for assignment to hline relative references in table formulas.
  2013-11-05 20:19       ` Achim Gratz
@ 2013-11-05 20:55         ` Bastien
  2013-11-07 19:37         ` Achim Gratz
  1 sibling, 0 replies; 9+ messages in thread
From: Bastien @ 2013-11-05 20:55 UTC (permalink / raw)
  To: Achim Gratz, Rick Frankel; +Cc: emacs-orgmode

Hi,

Achim Gratz <Stromeko@nexgo.de> writes:

> Bastien writes:
>>> * org-table.el (org-table-recalculate): Generate user error if
>>> an hline relative reference is use on the LHS of a formula.
>>
>> Applied, thanks!
>
> Rick is listed as a contributor, so the TINYCHANGE marker is wrong.

Yes, I realized that.

> Besides, that change breaks test-org-table/compare, which for whatever
> reason uses just such a LHS construct.

Rick, can you have a look at this problem?

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add check for assignment to hline relative references in table formulas.
  2013-11-05 20:19       ` Achim Gratz
  2013-11-05 20:55         ` Bastien
@ 2013-11-07 19:37         ` Achim Gratz
  2013-11-07 21:09           ` Bastien
  2013-11-08 11:09           ` Michael Brand
  1 sibling, 2 replies; 9+ messages in thread
From: Achim Gratz @ 2013-11-07 19:37 UTC (permalink / raw)
  To: emacs-orgmode

Achim Gratz writes:
> Besides, that change breaks test-org-table/compare, which for whatever
> reason uses just such a LHS construct.

I've fixed the failing test since it wasn't checking hline expressions
and hence should not have relied on undocumented behaviour in the first
place.


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

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add check for assignment to hline relative references in table formulas.
  2013-11-07 19:37         ` Achim Gratz
@ 2013-11-07 21:09           ` Bastien
  2013-11-08 11:09           ` Michael Brand
  1 sibling, 0 replies; 9+ messages in thread
From: Bastien @ 2013-11-07 21:09 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Achim Gratz <Stromeko@nexgo.de> writes:

> Achim Gratz writes:
>> Besides, that change breaks test-org-table/compare, which for whatever
>> reason uses just such a LHS construct.
>
> I've fixed the failing test since it wasn't checking hline expressions
> and hence should not have relied on undocumented behaviour in the first
> place.

Thanks for the fix Achim.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Add check for assignment to hline relative references in table formulas.
  2013-11-07 19:37         ` Achim Gratz
  2013-11-07 21:09           ` Bastien
@ 2013-11-08 11:09           ` Michael Brand
  1 sibling, 0 replies; 9+ messages in thread
From: Michael Brand @ 2013-11-08 11:09 UTC (permalink / raw)
  To: Achim Gratz; +Cc: Org Mode

Hi Achim

On Thu, Nov 7, 2013 at 8:37 PM, Achim Gratz <Stromeko@nexgo.de> wrote:
> I've fixed the failing test since it wasn't checking hline expressions
> and hence should not have relied on undocumented behaviour in the first
> place.

I agree that testing of "LHS hline ref range" and testing of something
else (in this case "comparison") at the same time in the same
ert-deftest has also disadvantages. But why did you only remove test
coverage of "LHS hline ref range" instead of move it into a new
ert-deftest?

Michael

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-11-08 11:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-01 17:27 [BUG] hline references on left side of table formula Rick Frankel
2013-09-02  8:10 ` Carsten Dominik
2013-09-25 17:57   ` [PATCH] Add check for assignment to hline relative references in table formulas Rick Frankel
2013-11-05 11:08     ` Bastien
2013-11-05 20:19       ` Achim Gratz
2013-11-05 20:55         ` Bastien
2013-11-07 19:37         ` Achim Gratz
2013-11-07 21:09           ` Bastien
2013-11-08 11:09           ` Michael Brand

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).