diff --git a/doc/ChangeLog b/doc/ChangeLog index 67d570991..4b8389beb 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2010-05-07 Carsten Dominik + + * org.texi (Updating the table): Document new buffer-wide + table commands. + 2010-04-26 Carsten Dominik * org.texi (Conflicts): Document new work-around for windmove.el. diff --git a/doc/org.texi b/doc/org.texi index 4fe4daa91..5fac58afd 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -2466,6 +2466,11 @@ hline are left alone, assuming that these are part of the table header. Iterate the table by recomputing it until no further changes occur. This may be necessary if some computed fields use the value of other fields that are computed @i{later} in the calculation sequence. +@item M-x org-table-recalculate-buffer-tables +Recompute all tables in the current buffer. +@item M-x org-table-iterate-buffer-tables +Iterate all tables in the current buffer, in order to converge table-to-table +dependencies. @end table @node Advanced features, , Updating the table, The spreadsheet diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 864070ca7..88d477eeb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-05-07 Carsten Dominik + * org-table.el (org-table-recalculate-buffer-tables) + (org-table-iterate-buffer-tables): New commands. + * org.el (org-check-for-hidden): When there is a region, skip the check. diff --git a/lisp/org-table.el b/lisp/org-table.el index 0e6995b1e..c8524cd4f 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2685,6 +2685,36 @@ known that the table will be realigned a little later anyway." (throw 'exit t))) (error "No convergence after %d iterations" i)))) +(defun org-table-recalculate-buffer-tables () + "Recalculate all tables in the current buffer." + (interactive) + (save-excursion + (save-restriction + (widen) + (org-table-map-tables (lambda () (org-table-recalculate t)) t)))) + +(defun org-table-iterate-buffer-tables () + "Iterate all tables in the buffer, to converge inter-table dependencies." + (interactive) + (let* ((imax 10) + (checksum (md5 (buffer-string))) + + c1 + (i imax)) + (save-excursion + (save-restriction + (widen) + (catch 'exit + (while (> i 0) + (setq i (1- i)) + (org-table-map-tables (lambda () (org-table-recalculate t)) t) + (if (equal checksum (setq c1 (md5 (buffer-string)))) + (progn + (message "Convergence after %d iterations" (- imax i)) + (throw 'exit t)) + (setq checksum c1))) + (error "No convergence after %d iterations" imax)))))) + (defun org-table-formula-substitute-names (f) "Replace $const with values in string F." (let ((start 0) a (f1 f) (pp (/= (string-to-char f) ?')))