From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johan Ekh Subject: Re: Iterate many tables Date: Fri, 14 May 2010 15:43:56 +0200 Message-ID: References: <4BE2A954.7010401@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0326687139==" Return-path: Received: from [140.186.70.92] (port=38261 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCvBJ-0001mu-Px for emacs-orgmode@gnu.org; Fri, 14 May 2010 09:44:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OCvBG-0005C8-VP for emacs-orgmode@gnu.org; Fri, 14 May 2010 09:44:01 -0400 Received: from fg-out-1718.google.com ([72.14.220.158]:61321) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OCvBG-0005By-Ia for emacs-orgmode@gnu.org; Fri, 14 May 2010 09:43:58 -0400 Received: by fg-out-1718.google.com with SMTP id 22so225518fge.12 for ; Fri, 14 May 2010 06:43:57 -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: Carsten Dominik Cc: emacs-orgmode@gnu.org --===============0326687139== Content-Type: multipart/alternative; boundary=001485f7721c1b733d04868e114f --001485f7721c1b733d04868e114f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi again, I removed "org-publish.el" and the upgrade worked. Thus I now have the latest version of org-mode. Guess what, your functions now work perfectly! Thanks! Johan On Fri, May 14, 2010 at 3:05 PM, Johan Ekh wrote: > Hi, > You're right, I'm actually not using the latest version. It fails to > install. I use the version "6.33trans". > When I try to upgrade with Git I get the compilation error: > > > In org-publish-get-base-files-1: > org-publish.el:407:13:Warning: reference to free variable > `sitemap-requested' > org-publish.el:915:1:Error: Invalid read syntax: "#" > make: *** [lisp/org-publish.elc] Error 1 > > > Do you know what is wrong? I checked line 915 in "org-publish.el" but the= re > is > no "#" in that line. > > Do you know what is wrong? > > Best regards, > Johan > > > On Fri, May 14, 2010 at 2:32 PM, Carsten Dominik < > carsten.dominik@gmail.com> wrote: > >> Hi Johan, >> >> I think you are not using the latest version of Org? Please upgrade. >> >> - Carsten >> >> >> On May 14, 2010, at 12:07 PM, Johan Ekh wrote: >> >> Hi, >>> I've tried the functions but I get the error described above. >>> I've put the functions in my .emacs exactly as written in the mail. >>> I use the latest org-mode (using Git) and I use emacs 23.1.1 on >>> a 64-bit openSuse 11.1 linux laptop. >>> >>> Do the cursor need to be located anywhere specific when executing >>> the functions? I've tried to execute the functions while having all >>> tables >>> expanded and the cursor somewhere in the last table. >>> >>> Best regards, >>> Johan >>> >>> On Fri, May 7, 2010 at 9:36 AM, Carsten Dominik < >>> carsten.dominik@gmail.com> wrote: >>> Hi, >>> >>> both functions work without any problem for me, so I do not know what y= ou >>> are doing differently. maybe you ned to describe exactly how you 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 (functio= n) >>> "Apply FUNCTION to the start of all tables in the buffer." (save-excurs= ion >>> (save-restriction (widen) (goto-char (point-min)) (while (re-search-for= ward >>> org-table-any-line-regexp nil t) (message "Mapping tables: %d%%" (/ (* = 100.0 >>> (point)) (buffer-size))) (beginning-of-line 1) (when (looking-at >>> org-table-line-regexp) (save-excursion (funcall function)) (or (looking= -at >>> org-table-line-regexp) (forward-char 1))) (re-search-forward >>> org-table-any-border-regexp nil 1)))) (message "Mapping tables: done"))= , 2 >>> >>> org-iterate-all-tables: >>> while: Wrong number of arguments: (lambda (function) "Apply FUNCTION to >>> the start of all tables in the buffer." (save-excursion (save-restricti= on >>> (widen) (goto-char (point-min)) (while (re-search-forward >>> org-table-any-line-regexp nil t) (message "Mapping tables: %d%%" (/ (* = 100.0 >>> (point)) (buffer-size))) (beginning-of-line 1) (when (looking-at >>> org-table-line-regexp) (save-excursion (funcall function)) (or (looking= -at >>> org-table-line-regexp) (forward-char 1))) (re-search-forward >>> org-table-any-border-regexp nil 1)))) (message "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) >>> "=C5=A0=C5=92~=CB=86eb=CB=86=C3=84 =C3=85=C3=86#=C6=92: >>> >>> >>> 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 >>> 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 >>> >>> >>> >>> _______________________________________________ >>> 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 >>> >>> >>> >>> >>> >>> _______________________________________________ >>> 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 >> >> >> >> > --001485f7721c1b733d04868e114f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi again,
I removed "org-publish.el" and the upgrade worked. T= hus I now have the latest version of org-mode.
Guess what, your function= s now work perfectly!

Thanks!

Johan

On Fri, May 14, 2010 at 3:05 PM, Johan Ekh <ekh.johan@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 2= 04, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi,
You're right, I'm actually not using the latest version. It = fails to install. I use the version "6.33trans".
When I try t= o upgrade with Git I get the compilation error:


In org-publish-g= et-base-files-1:
org-publish.el:407:13:Warning: reference to free variable `sitemap-requeste= d'
org-publish.el:915:1:Error: Invalid read syntax: "#"make: *** [lisp/org-publish.elc] Error 1


Do you know what is wr= ong? I checked line 915 in "org-publish.el" but there is
no "#" in that line.

Do you know what is wrong?

Bes= t regards,
Johan


On Fri, May 14, 2010 at 2:32 PM= , Carsten Dominik <carsten.dominik@gmail.com> wrote:=
Hi Johan,

I think you are not using the latest version of Org? =C2=A0Please upgrade.<= br>
- Carsten


On May 14, 2010, at 12:07 PM, Johan Ekh wrote:

Hi,
I've tried the functions but I get the error described above.
I've put the functions in my .emacs exactly as written in the mail.
I use the latest org-mode (using Git) and I use emacs 23.1.1 on
a 64-bit openSuse 11.1 linux laptop.

Do the cursor need to be located anywhere specific when executing
the functions? I've tried to execute the functions while having all tab= les
expanded and the cursor somewhere in the last table.

Best regards,
Johan

On Fri, May 7, 2010 at 9:36 AM, Carsten Dominik <carsten.dominik@gmail.com> w= rote:
Hi,

both functions work without any problem for me, so I do not know what you a= re doing differently. =C2=A0maybe you ned to describe exactly how you are c= alling 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 (function) &= quot;Apply FUNCTION to the start of all tables in the buffer." (save-e= xcursion (save-restriction (widen) (goto-char (point-min)) (while (re-searc= h-forward org-table-any-line-regexp nil t) (message "Mapping tables: %= d%%" (/ (* 100.0 (point)) (buffer-size))) (beginning-of-line 1) (when = (looking-at org-table-line-regexp) (save-excursion (funcall function)) (or = (looking-at org-table-line-regexp) (forward-char 1))) (re-search-forward or= g-table-any-border-regexp nil 1)))) (message "Mapping tables: done&quo= t;)), 2

org-iterate-all-tables:
while: Wrong number of arguments: (lambda (function) "Apply FUNCTION t= o the start of all tables in the buffer." (save-excursion (save-restri= ction (widen) (goto-char (point-min)) (while (re-search-forward org-table-a= ny-line-regexp nil t) (message "Mapping tables: %d%%" (/ (* 100.0= (point)) (buffer-size))) (beginning-of-line 1) (when (looking-at org-table= -line-regexp) (save-excursion (funcall function)) (or (looking-at org-table= -line-regexp) (forward-char 1))) (re-search-forward org-table-any-border-re= gexp nil 1)))) (message "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) "= =C5=A0=C5=92~=CB=86eb=CB=86=C3=84 =C3=85=C3=86#=C6=92:


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 ()
=C2=A0(interactive)
=C2=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 ()
=C2=A0(interactive)
=C2=A0(let* ((imax 10)
=C2=A0 =C2=A0 =C2=A0 (checksum (md5 (buffer-string)))
=C2=A0 =C2=A0 =C2=A0 c1
=C2=A0 =C2=A0 =C2=A0 (i imax))
=C2=A0(catch 'exit
=C2=A0 =C2=A0(while (> i 0)
=C2=A0 =C2=A0 =C2=A0(setq i (1- i))
=C2=A0 =C2=A0 =C2=A0(org-table-map-tables (lambda () (org-table-recalculat= e t)) t)
=C2=A0 =C2=A0 =C2=A0(if (equal checksum (setq c1 (md5 (buffer-string)))) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(progn
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "Convergence after = %d iterations" (- imax i))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(throw 'exit t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(setq checksum c1)))
=C2=A0 =C2=A0(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@gn= u.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@gn= u.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten





_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gn= u.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


- Carsten





--001485f7721c1b733d04868e114f-- --===============0326687139== 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 --===============0326687139==--