From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Iterate many tables Date: Fri, 7 May 2010 09:36:57 +0200 Message-ID: References: <4BE2A954.7010401@gmail.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OANwT-0004wc-4F for emacs-orgmode@gnu.org; Fri, 07 May 2010 09:50:13 -0400 Received: from [140.186.70.92] (port=53267 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OANwI-0003Ka-VM for emacs-orgmode@gnu.org; Fri, 07 May 2010 09:50:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OAIiO-0003Ov-Qf for emacs-orgmode@gnu.org; Fri, 07 May 2010 04:15:24 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:54967) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OAI7W-0005Xp-2G for emacs-orgmode@gnu.org; Fri, 07 May 2010 03:37:18 -0400 Received: by wyb40 with SMTP id 40so254429wyb.0 for ; Fri, 07 May 2010 00:37:13 -0700 (PDT) In-Reply-To: <4BE2A954.7010401@gmail.com> 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: maxco.tr@gmail.com Cc: emacs-orgmode@gnu.org Hi, both functions work without any problem for me, so I do not know what =20= you are doing differently. maybe you ned to describe exactly how you =20= are calling the functions. - Carsten On May 6, 2010, at 1:34 PM, T Helms wrote: > Thanks for bringing this up, it would be a useful tool. > > I get an error using the functions as well > > org-recalculate-all-tables: > org-recalculate-all-tables: Wrong number of arguments: (lambda =20 > (function) "Apply FUNCTION to the start of all tables in the =20 > buffer." (save-excursion (save-restriction (widen) (goto-char (point-=20= > min)) (while (re-search-forward org-table-any-line-regexp nil t) =20 > (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size))) =20= > (beginning-of-line 1) (when (looking-at org-table-line-regexp) (save-=20= > excursion (funcall function)) (or (looking-at org-table-line-regexp) =20= > (forward-char 1))) (re-search-forward org-table-any-border-regexp =20 > nil 1)))) (message "Mapping tables: done")), 2 > > org-iterate-all-tables: > while: Wrong number of arguments: (lambda (function) "Apply FUNCTION =20= > to the start of all tables in the buffer." (save-excursion (save-=20 > restriction (widen) (goto-char (point-min)) (while (re-search-=20 > forward org-table-any-line-regexp nil t) (message "Mapping tables: %d=20= > %%" (/ (* 100.0 (point)) (buffer-size))) (beginning-of-line 1) (when =20= > (looking-at org-table-line-regexp) (save-excursion (funcall =20 > function)) (or (looking-at org-table-line-regexp) (forward-char 1))) =20= > (re-search-forward org-table-any-border-regexp nil 1)))) (message =20 > "Mapping tables: done")), 2 > > > On 05/05/2010 03:37 PM, Johan Ekh wrote: >> >> >> >> Any idea what could be wrong? >> >> >> >> Error meassage: >> >> org-recalculate-all-tables: Wrong number of arguments: #[(function) =20= >> "=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 =20 >> fields that depends on fields >> in the previous table. Thus, if I change something in the first =20 >> table, I must go down manually >> and recalculate (or iterate) each table. Is there a way to =20 >> 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 =20 >> (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 >> >> >> >> _______________________________________________ >> 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 >> > _______________________________________________ > 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 - Carsten