0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 20:37:51 +00:00

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.
This commit is contained in:
Michael Brand 2016-10-21 17:35:13 +02:00
parent e66298dfd9
commit 359afa6806
2 changed files with 13 additions and 5 deletions

View file

@ -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)

View file

@ -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)