diff --git a/lisp/org-table.el b/lisp/org-table.el index 866abc2ff..fd5bc8792 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -1368,8 +1368,8 @@ However, when FORCE is non-nil, create new columns if necessary." ;; Fix TBLFM formulas, if desirable. (when (or (not org-table-fix-formulas-confirm) (funcall org-table-fix-formulas-confirm "Fix formulas? ")) - (org-table-fix-formulas "$" nil (1- col) 1) - (org-table-fix-formulas "$LR" nil (1- col) 1)))) + (org-table-fix-formulas "$" nil col 1) + (org-table-fix-formulas "$LR" nil col 1)))) (defun org-table-find-dataline () "Find a data line in the current table, which is needed for column commands. diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 565f3ff74..14094deb6 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -2394,6 +2394,16 @@ See also `test-org-table/copy-field'." (org-table-insert-column) (buffer-string))))) +(ert-deftest test-org-table/insert-column-with-formula () + "Test `org-table-insert-column' with a formula in place." + (should + (equal "| 1 | | 1 | 2 | +#+TBLFM: $4=$1+$3" + (org-test-with-temp-text + "| 1 | 1 | 2 | +#+TBLFM: $3=$1+$2" + (org-table-insert-column) + (buffer-substring-no-properties (point-min) (point-max)))))) ;;; Moving single cells