From: Piotr Gajewski <pg7@outlook.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
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 [thread overview]
Message-ID: <DUB122-W36E8EB70800D9097A1ADCFFC0E0@phx.gbl> (raw)
* lisp/org-table.el (org-table-eval-formula): Fix regexp
used for splitting data rows.
* Explanation /root node/
*** Example 1: Spaces ' ' in front of a data row (OK)
|---+-----+------+---+----+-----|
| ! | sum | | a | b | c |
|---+-----+------+---+----+-----|
| # | 111 | 1000 | 1 | 10 | 100 |
|---+-----+------+---+----+-----|
#+TBLFM: $2=$a+$b+$c
List of values after splitting data row:
("#" "" "1000" "1" "10" "100")
Formula is computed correctly.
*** Example 2: Tabulators '\t' in front of a data row (ERROR)
|---+------+------+---+----+-----|
| ! | sum | | a | b | c |
|---+------+------+---+----+-----|
| # | 1011 | 1000 | 1 | 10 | 100 |
|---+------+------+---+----+-----|
#+TBLFM: $2=$a+$b+$c
List of values after splitting data row:
("\t" "#" "" "1000" "1" "10" "100")
There is an extra field containing '\t' character(s).
All /genuine/ values are shifted to the right.
Consequently, references to fields lookup the wrong values.
TINYCHANGE
---
lisp/org-table.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 17424be..9ed8b6e 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2723,7 +2723,7 @@ not overwrite the stored one."
(while (> ndown 0)
(setq fields (org-split-string
(buffer-substring-no-properties (point-at-bol) (point-at-eol))
- " *| *"))
+ "[ \t]*|[ \t]*"))
;; replace fields with duration values if relevant
(if duration
(setq fields
--
1.9.5.msysgit.0
reply other threads:[~2015-12-02 11:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=DUB122-W36E8EB70800D9097A1ADCFFC0E0@phx.gbl \
--to=pg7@outlook.com \
--cc=emacs-orgmode@gnu.org \
--cc=piotr.gajewski@windowslive.com \
/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).