diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-06-09 14:53:18 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-06-09 15:03:27 +0200 |
commit | 3924989b4f45a5c7ff89a4f7abdebc570cbaf7e2 (patch) | |
tree | 448c739dbc70ec7d32d4d027c4104a9c2af5d628 | |
parent | c532ff36aac60f337616cf16595b2e622e0fa465 (diff) | |
download | org-mode-3924989b4f45a5c7ff89a4f7abdebc570cbaf7e2.tar.gz |
org-table: Fix formulas with relative ranges in current row
* lisp/org-table.el (org-table-eval-formula): Fix formulas with
relative ranges in current row.
Reported-by: Eric S Fraga <e.fraga@ucl.ac.uk>
<http://permalink.gmane.org/gmane.emacs.orgmode/97727>
-rw-r--r-- | lisp/org-table.el | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index 8a6e22b..0350af5 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2790,15 +2790,19 @@ not overwrite the stored one." (string-match (regexp-quote form) formrpl))) (setq form (replace-match formrpl t t form)) (user-error "Spreadsheet error: invalid reference \"%s\"" form))) - ;; Insert simple ranges - (while (string-match "\\$\\([0-9]+\\)\\.\\.\\$\\([0-9]+\\)" form) + ;; Insert simple ranges, i.e. included in the current row. + (while (string-match + "\\$\\(\\([-+]\\)?[0-9]+\\)\\.\\.\\$\\(\\([-+]\\)?[0-9]+\\)" + form) (setq form (replace-match (save-match-data (org-table-make-reference - (org-sublist - fields (string-to-number (match-string 1 form)) - (string-to-number (match-string 2 form))) + (org-sublist fields + (+ (if (match-end 2) n0 0) + (string-to-number (match-string 1 form))) + (+ (if (match-end 4) n0 0) + (string-to-number (match-string 3 form)))) keep-empty numbers lispp)) t t form))) (setq form0 form) |