diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-15 17:40:22 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-15 17:40:22 +0100 |
commit | 6059c3a057ca4739a77c3ad4b493650c48f410cd (patch) | |
tree | 718d928608fe9bcbde76d6b0b6ab19c2eaac52d1 | |
parent | 18af0f88d7f669a750ad1526db3975940793d734 (diff) | |
download | org-mode-6059c3a057ca4739a77c3ad4b493650c48f410cd.tar.gz |
org-table: Clean left-over `:org-untouchable' property
* lisp/org-table.el (org-table-recalculate): Clean `:org-untouchable'
property once we no longer need it.
* testing/lisp/test-org-table.el (test-org-table/formula-priority):
New test.
Reported-by: Ruy Exel <ruyexel@gmail.com>
<http://lists.gnu.org/archive/html/emacs-orgmode/2017-11/msg00159.html>
-rw-r--r-- | lisp/org-table.el | 5 | ||||
-rw-r--r-- | testing/lisp/test-org-table.el | 21 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index 8dc648e..b4c72a4 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -3270,7 +3270,9 @@ existing formula for column %s" (org-table-goto-field name) (org-table-put-field-property :org-untouchable t))))) ;; Evaluate the column formulas, but skip fields covered by - ;; field formulas. + ;; field formulas. This is done by setting + ;; `:org-untouchable' property on such fields. The property + ;; is them removed once column formulas have been applied. (goto-char beg) (while (re-search-forward line-re end t) (unless (string-match "\\` *[_^!$/] *\\'" (org-table-get-field 1)) @@ -3292,6 +3294,7 @@ existing formula for column %s" (unless (get-text-property (point) :org-untouchable) (org-table-eval-formula nil (cdr entry) 'noalign 'nocst 'nostore 'noanalysis))))) + (remove-text-properties beg end '(:org-untouchable)) ;; Evaluate the field formulas. (dolist (eq eqlfield) (let ((reference (car eq)) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 63234e3..92960da 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1906,6 +1906,27 @@ is t, then new columns should be added as needed" (org-table-calc-current-TBLFM) (buffer-string))))) +(ert-deftest test-org-table/formula-priority () + "Test field formula priority over column formula." + ;; Field formulas bind stronger than column formulas. + (should + (equal + "| 1 | 3 |\n| 2 | 99 |\n" + (org-test-with-temp-text + "| 1 | |\n| 2 | |\n<point>#+tblfm: $2=3*$1::@2$2=99" + (org-table-calc-current-TBLFM) + (buffer-substring-no-properties (point-min) (point))))) + ;; When field formula is removed, table formulas is applied again. + (should + (equal + "| 1 | 3 |\n| 2 | 6 |\n" + (org-test-with-temp-text + "| 1 | |\n| 2 | |\n#+tblfm: $2=3*$1<point>::@2$2=99" + (org-table-calc-current-TBLFM) + (delete-region (point) (line-end-position)) + (org-table-calc-current-TBLFM) + (buffer-substring-no-properties (point-min) (line-beginning-position)))))) + (ert-deftest test-org-table/tab-indent () "Test named fields with tab indentation." (should |