mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-29 20:35:02 +00:00
Add commands to recalculate and iterate all tables in a buffer
This was a request by Johna Ekh.
This commit is contained in:
parent
6a98418b66
commit
e27bc453de
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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) ?')))
|
||||
|
Loading…
Reference in New Issue
Block a user