emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rick Frankel <rick@rickster.com>
To: Bastien <bzg@gnu.org>
Cc: lompik@voila.fr, Stromeko@nexgo.de, emacs-orgmode@gnu.org
Subject: Re: [BUG] hline references on left side of table formula
Date: Wed, 06 Nov 2013 13:50:17 -0500	[thread overview]
Message-ID: <39f042b047fcc17e87f5ceb8ebd3e038@mail.rickster.com> (raw)
In-Reply-To: <874n7pgawr.fsf@bzg.ath.cx>

On 2013-11-06 03:23, Bastien wrote:
> lompik@voila.fr 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 =@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.

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

  reply	other threads:[~2013-11-06 18:50 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 [this message]
2013-11-06 19:57     ` Achim Gratz
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=39f042b047fcc17e87f5ceb8ebd3e038@mail.rickster.com \
    --to=rick@rickster.com \
    --cc=Stromeko@nexgo.de \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=lompik@voila.fr \
    /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).