From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz Subject: Re: [BUG] hline references on left side of table formula Date: Wed, 06 Nov 2013 20:57:29 +0100 Message-ID: <87ob5xtiae.fsf@Rainer.invalid> References: <2027056056.183911380605538292.JavaMail.www@wwinf7113> <874n7pgawr.fsf@bzg.ath.cx> <39f042b047fcc17e87f5ceb8ebd3e038@mail.rickster.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve9F9-0007DC-3S for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 14:58:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve9F2-00025Y-Uq for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 14:58:23 -0500 Received: from plane.gmane.org ([80.91.229.3]:55272) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve9F2-000259-NB for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 14:58:16 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ve9Eg-0007iR-T7 for emacs-orgmode@gnu.org; Wed, 06 Nov 2013 20:57:54 +0100 Received: from pd9eb1e31.dip0.t-ipconnect.de ([217.235.30.49]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 06 Nov 2013 20:57:54 +0100 Received: from Stromeko by pd9eb1e31.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 06 Nov 2013 20:57:54 +0100 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: emacs-orgmode@gnu.org Rick Frankel writes: > 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. 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(@-II..@-I) > 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 > > > > -- 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