diff options
author | Bastien Guerry <bzg@altern.org> | 2014-07-27 15:05:48 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2014-07-27 15:05:48 +0200 |
commit | d4799ebfc168a6dd282dbb9c980b7c5ceeb39100 (patch) | |
tree | c57fa975d99e27bef1904537b6f01cfce05e0e5a | |
parent | 656cd3c76ea38b09a73c6fd340c2c6b662fd08f1 (diff) | |
download | org-mode-d4799ebfc168a6dd282dbb9c980b7c5ceeb39100.tar.gz |
org-table.el (org-table-eval-formula): Better error throwing
* org-table.el (org-table-eval-formula): Throw an error when
trying to replace a wrong formula specifier.
Thanks to Alejandro Suarez for reporting this.
-rw-r--r-- | lisp/org-table.el | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index 0b7f64a..bc32c45 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2758,15 +2758,17 @@ not overwrite the stored one." (while (string-match "\\$\\(\\([-+]\\)?[0-9]+\\)" form) (setq n (+ (string-to-number (match-string 1 form)) (if (match-end 2) n0 0)) - x (nth (1- (if (= n 0) n0 (max n 1))) fields)) - (unless x (user-error "Invalid field specifier \"%s\"" - (match-string 0 form))) - (setq form (replace-match - (save-match-data - (org-table-make-reference - x keep-empty numbers lispp)) - t t form))) - + x (nth (1- (if (= n 0) n0 (max n 1))) fields) + formrpl (save-match-data + (org-table-make-reference + x keep-empty numbers lispp))) + (when (or (not x) + (save-match-data + (string-match (regexp-quote formula) formrpl))) + (user-error "Invalid field specifier \"%s\"" + (match-string 0 form))) + (setq form (replace-match repl t t form))) + (if lispp (setq ev (condition-case nil (eval (eval (read form))) |