emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [BUG] hline references on left side of table formula


From: Rick Frankel
Subject: Re: [O] [BUG] hline references on left side of table formula
Date: Wed, 06 Nov 2013 13:50:17 -0500
User-agent: Roundcube Webmail/0.9.0

On 2013-11-06 03:23, Bastien wrote:
address@hidden writes:

I was interested to use hline references on the left side. However I found out that it
is not completely unsupported.
When the left side consist of:
* single cells references, it does not work
* ranged cells, it works for me (org 8.0.3)

(I'm not sure I fully understand the issue.)

The patch below tranforms the single cell references to ranged cells .

However it still does not work for references like @+ or @- I$1.. ,
which can be solve using references like @I+1#1.

If you come up with a complete patch, please submit it by following
the guidelines here: http://orgmode.org/worg/org-contribute.html

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.

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]