From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Frankel Subject: Re: [BUG] hline references on left side of table formula Date: Wed, 06 Nov 2013 13:50:17 -0500 Message-ID: <39f042b047fcc17e87f5ceb8ebd3e038@mail.rickster.com> References: <2027056056.183911380605538292.JavaMail.www@wwinf7113> <874n7pgawr.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve8BK-0005fb-De for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 13:50:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve8BF-0005B3-EW for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 13:50:22 -0500 Received: from [204.62.15.78] (port=43071 helo=mail.rickster.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve8BF-0005Az-AD for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 13:50:17 -0500 In-Reply-To: <874n7pgawr.fsf@bzg.ath.cx> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: lompik@voila.fr, Stromeko@nexgo.de, emacs-orgmode@gnu.org 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