summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-08-29 00:29:37 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-08-29 00:43:38 +0200
commit2dfdafd35afac6cdd8bdb6abd8a0bb05896345d2 (patch)
treedf4c052527cc115952baea1158be28c91bcd20e3
parentb7c144a104641c2680ec8bd1f3092698fcca038c (diff)
downloadorg-mode-2dfdafd35afac6cdd8bdb6abd8a0bb05896345d2.tar.gz
org-table: Fix column formulas
* lisp/org-table.el (org-table-recalculate): Fix column formulas in tables consisting of a single row group. Reported-by: Michael Welle <mwe012008@gmx.net> <http://permalink.gmane.org/gmane.emacs.orgmode/108886>
-rw-r--r--lisp/org-table.el4
-rw-r--r--testing/lisp/test-org-table.el27
2 files changed, 29 insertions, 2 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index c57eb5d..5a2e31e 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3199,8 +3199,8 @@ existing formula for column %s"
(re-search-forward org-table-hline-regexp end t)
(re-search-forward org-table-dataline-regexp end t))
(setq beg (match-beginning 0)))
- ;; Just leave BEG where it is.
- (t (setq beg (line-beginning-position)))))
+ ;; Just leave BEG at the start of the table.
+ (t nil)))
(setq beg (line-beginning-position)
end (copy-marker (line-beginning-position 2))))
(goto-char beg)
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index efa88fd..89912af 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -1909,6 +1909,33 @@ is t, then new columns should be added as needed"
(org-table-calc-current-TBLFM)
(buffer-string)))))
+(ert-deftest test-org-table/single-rowgroup ()
+ "Test column formula in a table with a single rowgroup."
+ (should
+ (equal
+ "
+|---+---|
+| 1 | 0 |
+|---+---|
+#+TBLFM: $2=$1-1"
+ (org-test-with-temp-text "
+|---+---|
+| 1 | |
+|---+---|
+<point>#+TBLFM: $2=$1-1"
+ (org-table-calc-current-TBLFM)
+ (buffer-string))))
+ (should
+ (equal
+ "
+| 1 | 0 |
+#+TBLFM: $2=$1-1"
+ (org-test-with-temp-text "
+| 1 | |
+<point>#+TBLFM: $2=$1-1"
+ (org-table-calc-current-TBLFM)
+ (buffer-string)))))
+
(provide 'test-org-table)