From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johan Ekh Subject: Re: Iterate many tables Date: Wed, 5 May 2010 21:37:20 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1076863410==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9kPN-0003eQ-Dk for emacs-orgmode@gnu.org; Wed, 05 May 2010 15:37:25 -0400 Received: from [140.186.70.92] (port=37547 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9kPL-0003cD-MP for emacs-orgmode@gnu.org; Wed, 05 May 2010 15:37:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9kPJ-0006fT-Ts for emacs-orgmode@gnu.org; Wed, 05 May 2010 15:37:23 -0400 Received: from mail-fx0-f41.google.com ([209.85.161.41]:46930) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9kPJ-0006f3-Km for emacs-orgmode@gnu.org; Wed, 05 May 2010 15:37:21 -0400 Received: by fxm1 with SMTP id 1so4558418fxm.0 for ; Wed, 05 May 2010 12:37:20 -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: emacs-orgmode@gnu.org --===============1076863410== Content-Type: multipart/alternative; boundary=001636499eb359626d0485ddf410 --001636499eb359626d0485ddf410 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I only have backward dependencies so I tried the first code block. I put it in ..emacs and tried, but I got a message starting as the message below. I could not paste it into the email for some reason... The tables work as expected when I do it manually. Any idea what could be wrong? Error meassage: org-recalculate-all-tables: Wrong number of arguments: #[(function) "=8A=8C~=88eb=88=C4=08=C5=C6#=83: Best regards, Johan On Fri, Apr 30, 2010 at 5:03 PM, Carsten Dominik 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 a= ll >> 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 > > --001636499eb359626d0485ddf410 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I only have backward dependencies so I tried the first code block.
I put= it in ..emacs and tried, but I got a message starting as the message below= .
I could not paste it into the email for some reason...

The tab= les work as expected when I do it manually.

Any idea what could be wrong?



Error meassage:

org= -recalculate-all-tables: Wrong number of arguments: #[(function) "=8A= =8C~=88eb=88=C4=08=C5=C6#=83:


Best regards,
Johan


=



On Fri, Apr 30, 2010 at 5:03 PM, Carsten Dominik= <carsten= .dominik@gmail.com> 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 tha= t depends on fields
in the previous table. Thus, if I change something in the first table, I mu= st 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 ()
=A0 (interactive)
=A0 (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 ()
=A0(interactive)
=A0(let* ((imax 10)
=A0 =A0 =A0 =A0 (checksum (md5 (buffer-string)))
=A0 =A0 =A0 =A0 c1
=A0 =A0 =A0 =A0 (i imax))
=A0 =A0(catch 'exit
=A0 =A0 =A0(while (> i 0)
=A0 =A0 =A0 =A0(setq i (1- i))
=A0 =A0 =A0 =A0(org-table-map-tables (lambda () (org-table-recalculate t))= t)
=A0 =A0 =A0 =A0(if (equal checksum (setq c1 (md5 (buffer-string))))
=A0 =A0 =A0 =A0 =A0 =A0(progn
=A0 =A0 =A0 =A0 =A0 =A0 =A0(message "Convergence after %d iterations&= quot; (- imax i))
=A0 =A0 =A0 =A0 =A0 =A0 =A0(throw 'exit t))
=A0 =A0 =A0 =A0 =A0(setq checksum c1)))
=A0 =A0 =A0(error "No convergence after %d iterations" imax))))<= br>
If it does, this could be added to org-hacks on Worg.

HTH

- Carsten


--001636499eb359626d0485ddf410-- --===============1076863410== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1076863410==--