summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2011-03-03 17:46:24 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2011-03-03 22:16:35 +0100
commit4161d85da808d66abf5211de48a96e15501aab03 (patch)
tree2a01292663a6289f0b7116ac3aa3c2ef14d1abd3
parent3bff7ce7761574439a0052cc7965e2411a8ef82b (diff)
downloadorg-mode-4161d85da808d66abf5211de48a96e15501aab03.tar.gz
Fix relative column references
* lisp/org-table.el (org-table-eval-formula): Treat relative column refs. I cannot believe this did not work and nobody complained about this. $-1 is supposed to refer to the value in the column to the left. Now this does work.
-rw-r--r--lisp/org-table.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index df4920d..7ccd3cd 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2394,9 +2394,13 @@ not overwrite the stored one."
t t form)))
(setq form0 form)
;; Insert the references to fields in same row
- (while (string-match "\\$\\([0-9]+\\)" form)
- (setq n (string-to-number (match-string 1 form))
- x (nth (1- (if (= n 0) n0 n)) fields))
+ (while (string-match "\\$\\([-+]?[0-9]+\\)" form)
+ (setq n (+ (string-to-number (match-string 1 form))
+ (if (member (substring form (match-beginning 1)
+ (1+ (match-beginning 1)))
+ '("+" "-"))
+ n0 0))
+ x (nth (1- (if (= n 0) n0 (max n 1))) fields))
(unless x (error "Invalid field specifier \"%s\""
(match-string 0 form)))
(setq form (replace-match