diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2010-05-07 09:45:34 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2010-05-07 09:45:34 +0200 |
commit | e27bc453de8783ef0d845b9101ae636ff8838465 (patch) | |
tree | e7a96423e2463a044eccf04aebfb9079b88601de | |
parent | 6a98418b6651518c67b861303e92ec48e0e9fad9 (diff) | |
download | org-mode-e27bc453de8783ef0d845b9101ae636ff8838465.tar.gz |
Add commands to recalculate and iterate all tables in a buffer
This was a request by Johna Ekh.
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/org.texi | 5 | ||||
-rw-r--r-- | lisp/ChangeLog | 3 | ||||
-rw-r--r-- | lisp/org-table.el | 30 |
4 files changed, 43 insertions, 0 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 67d5709..4b8389b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2010-05-07 Carsten Dominik <carsten.dominik@gmail.com> + + * org.texi (Updating the table): Document new buffer-wide + table commands. + 2010-04-26 Carsten Dominik <carsten.dominik@gmail.com> * org.texi (Conflicts): Document new work-around for windmove.el. diff --git a/doc/org.texi b/doc/org.texi index 4fe4daa..5fac58a 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 864070c..88d477e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2010-05-07 Carsten Dominik <carsten.dominik@gmail.com> + * 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 0e6995b..c8524cd 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) ?'))) |