From 359afa68060cee6a72707f53d69e1f9244cbc50c Mon Sep 17 00:00:00 2001 From: Michael Brand Date: Fri, 21 Oct 2016 17:35:13 +0200 Subject: [PATCH] Fix table align when recalculating buffer tables * lisp/org-table.el (org-table-recalculate-buffer-tables): Align all tables in a buffer. (org-table-iterate-buffer-tables): Align a table only once, align all tables in a buffer. --- lisp/org-table.el | 13 +++++++++++-- testing/lisp/test-org-table.el | 5 ++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index f64cd9188..6dcf10795 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -3321,7 +3321,14 @@ with the prefix ARG." "Recalculate all tables in the current buffer." (interactive) (org-with-wide-buffer - (org-table-map-tables (lambda () (org-table-recalculate t)) t))) + (org-table-map-tables + (lambda () + ;; Reason for separate `org-table-align': When repeating + ;; (org-table-recalculate t) `org-table-may-need-update' gets in + ;; the way. + (org-table-recalculate t t) + (org-table-align)) + t))) ;;;###autoload (defun org-table-iterate-buffer-tables () @@ -3335,12 +3342,14 @@ with the prefix ARG." (catch 'exit (while (> i 0) (setq i (1- i)) - (org-table-map-tables (lambda () (org-table-recalculate t)) t) + (org-table-map-tables (lambda () (org-table-recalculate t t)) t) (if (equal checksum (setq c1 (md5 (buffer-string)))) (progn + (org-table-map-tables #'org-table-align t) (message "Convergence after %d iterations" (- imax i)) (throw 'exit t)) (setq checksum c1))) + (org-table-map-tables #'org-table-align t) (user-error "No convergence after %d iterations" imax))))) (defun org-table-calc-current-TBLFM (&optional arg) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index bd8437f69..16edb264d 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -174,11 +174,10 @@ | c d | ") - ;; FIXME: Tables should be aligned. (after " -| a b | +| a b | -| c d | +| c d | ")) (should (equal (org-test-with-temp-text before (org-table-recalculate-buffer-tables) -- 2.11.4.GIT