From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Iterate many tables Date: Fri, 30 Apr 2010 17:03:22 +0200 Message-ID: References: Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7rkY-0001mf-Df for emacs-orgmode@gnu.org; Fri, 30 Apr 2010 11:03:30 -0400 Received: from [140.186.70.92] (port=42615 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7rkW-0001mW-2O for emacs-orgmode@gnu.org; Fri, 30 Apr 2010 11:03:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7rkU-0001e8-BP for emacs-orgmode@gnu.org; Fri, 30 Apr 2010 11:03:27 -0400 Received: from mail-ew0-f214.google.com ([209.85.219.214]:34247) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7rkU-0001e3-40 for emacs-orgmode@gnu.org; Fri, 30 Apr 2010 11:03:26 -0400 Received: by ewy6 with SMTP id 6so121415ewy.32 for ; Fri, 30 Apr 2010 08:03:25 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Johan Ekh Cc: emacs-orgmode@gnu.org 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 () (interactive) (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 () (interactive) (let* ((imax 10) (checksum (md5 (buffer-string))) c1 (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)))) (progn (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. HTH - Carsten