From mboxrd@z Thu Jan 1 00:00:00 1970 From: Piotr Gajewski Subject: [PATCH] org-table.el: Fix regexp used for splitting data rows when computing a formula Date: Wed, 2 Dec 2015 12:27:34 +0100 Message-ID: Reply-To: piotr.gajewski@windowslive.com Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a45sp-0001rZ-41 for emacs-orgmode@gnu.org; Wed, 02 Dec 2015 06:47:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a45sl-0003zN-Uc for emacs-orgmode@gnu.org; Wed, 02 Dec 2015 06:47:39 -0500 Received: from dub004-omc1s11.hotmail.com ([157.55.0.210]:59663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a45sl-0003z9-Mg for emacs-orgmode@gnu.org; Wed, 02 Dec 2015 06:47:35 -0500 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" * lisp/org-table.el (org-table-eval-formula): Fix regexp=0A= =A0 used for splitting data rows.=0A= =0A= * Explanation /root node/=0A= =0A= *** Example 1: Spaces ' ' in front of a data row (OK)=0A= =0A= =A0=A0=A0 |---+-----+------+---+----+-----|=0A= =A0=A0=A0 | ! | sum |=A0=A0=A0=A0=A0 | a |=A0 b |=A0=A0 c |=0A= =A0=A0=A0 |---+-----+------+---+----+-----|=0A= =A0=A0=A0 | # | 111 | 1000 | 1 | 10 | 100 |=0A= =A0=A0=A0 |---+-----+------+---+----+-----|=0A= =A0=A0=A0 #+TBLFM: $2=3D$a+$b+$c=0A= =0A= =A0=A0=A0 List of values after splitting data row:=0A= =A0=A0=A0 ("#" "" "1000" "1" "10" "100")=0A= =0A= =A0=A0=A0 Formula is computed correctly.=0A= =0A= *** Example 2: Tabulators '\t' in front of a data row (ERROR)=0A= =0A= =A0=A0 =A0|---+------+------+---+----+-----|=0A= =A0=A0 =A0| ! |=A0 sum |=A0=A0=A0=A0=A0 | a |=A0 b |=A0=A0 c |=0A= =A0=A0 =A0|---+------+------+---+----+-----|=0A= =A0=A0 =A0| # | 1011 | 1000 | 1 | 10 | 100 |=0A= =A0=A0 =A0|---+------+------+---+----+-----|=0A= =A0=A0 =A0#+TBLFM: $2=3D$a+$b+$c=0A= =0A= =A0=A0=A0 List of values after splitting data row:=0A= =A0=A0=A0 ("\t" "#" "" "1000" "1" "10" "100")=0A= =0A= =A0=A0=A0 There is an extra field containing '\t' character(s).=0A= =A0=A0=A0 All /genuine/ values are shifted to the right.=0A= =A0=A0=A0 Consequently=2C references to fields lookup the wrong values.=0A= =0A= TINYCHANGE=0A= ---=0A= =A0lisp/org-table.el | 2 +-=0A= =A01 file changed=2C 1 insertion(+)=2C 1 deletion(-)=0A= =0A= diff --git a/lisp/org-table.el b/lisp/org-table.el=0A= index 17424be..9ed8b6e 100644=0A= --- a/lisp/org-table.el=0A= +++ b/lisp/org-table.el=0A= @@ -2723=2C7 +2723=2C7 @@ not overwrite the stored one."=0A= =A0=A0=A0=A0=A0=A0 (while (> ndown 0)=0A= =A0=A0=A0 =A0(setq fields (org-split-string=0A= =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0 (buffer-substring-no-properties (poi= nt-at-bol) (point-at-eol))=0A= -=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0 " *| *"))=0A= +=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0 "[ \t]*|[ \t]*"))=0A= =A0=A0=A0 =A0=3B=3B replace fields with duration values if relevant=0A= =A0=A0=A0 =A0(if duration=0A= =A0=A0=A0 =A0=A0=A0=A0 (setq fields=0A= -- =0A= 1.9.5.msysgit.0=0A= =0A= =