[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Iterate many tables

From: Johan Ekh
Subject: Re: [Orgmode] Iterate many tables
Date: Mon, 3 May 2010 22:14:25 +0200

I will try it and report back.

On Fri, Apr 30, 2010 at 5:03 PM, Carsten Dominik <address@hidden> wrote:

On Apr 30, 2010, at 4:07 PM, Johan Ekh wrote:

Hi all,
I have a series of tables in a single file. Each table have some fields that depends on fields
in the previous table. Thus, if I change something in the first table, I must go down manually
and recalculate (or iterate) each table. Is there a way to recalculate all tables in a file simultaneously?

Hi Johan,

This should work if the dependence is only backwards.

(defun org-recalculate-all-tables ()
  (org-table-map-tables (lambda () (org-table-recalculate t)) t))

If you have dependencies in both directions, this might work (untested):

(defun org-iterate-all-tables ()
 (let* ((imax 10)
        (checksum (md5 (buffer-string)))
        (i imax))
   (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))))
             (message "Convergence after %d iterations" (- imax i))
             (throw 'exit t))
         (setq checksum c1)))
     (error "No convergence after %d iterations" imax))))

If it does, this could be added to org-hacks on Worg.


- Carsten

reply via email to

[Prev in Thread] Current Thread [Next in Thread]