diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2011-08-25 08:16:00 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2011-08-25 08:16:00 +0200 |
commit | e91f6db1e3ddae0f0db035eaf4699e423308476f (patch) | |
tree | c8f631492652b2592c19bc5c75e016e2675c1100 | |
parent | 984318cea532b61fcf1afb6fc6f3970a0a4de2c0 (diff) | |
download | org-mode-e91f6db1e3ddae0f0db035eaf4699e423308476f.tar.gz |
Keep table row/column removal from creating invalid formulas
* lisp/org-table.el (org-table-fix-formulas): Throw error when changing
formula leads to an invalid formula.
This fix catches at least one case, the one described by Nicolas:
> | 1 | 2 | 3 |
> | 1 | 2 | 3 |
> #+TBLFM: @2$1..@2$3=@1
> If I remove the second column (M-S-Left), the formula is correctly
> updated. But when I remove the last column, the formula gets partly
> deleted and becomes:
>
> #+TBLFM: @2$1..
>
-rw-r--r-- | lisp/org-table.el | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index 03b1126..c35e770 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2136,7 +2136,10 @@ For all numbers larger than LIMIT, shift them by DELTA." (when remove (while (re-search-forward re2 (point-at-eol) t) (unless (save-match-data (org-in-regexp "remote([^)]+?)")) - (replace-match "")))) + (if (equal (char-before (match-beginning 0)) ?.) + (error "Change makes TBLFM term %s invalid. Use undo to recover." + (match-string 0)) + (replace-match ""))))) (while (re-search-forward re (point-at-eol) t) (unless (save-match-data (org-in-regexp "remote([^)]+?)")) (setq s (match-string 1) n (string-to-number s)) |