emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] on export resulting in endless evaluation
@ 2015-02-06 10:06 Rainer M Krug
  2015-02-06 17:50 ` Charles Berry
  0 siblings, 1 reply; 7+ messages in thread
From: Rainer M Krug @ 2015-02-06 10:06 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 944 bytes --]


Hi

when exporting the fillowing org file, I get an endless loop of
evaluations.

This happens with only orgmode and languages enabled

,----
| GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, Carbon Version 157 AppKit 1343.16) of 2015-02-02 on Rainers-MacBook-Pro-4.local
| Org-mode version 8.3beta (release_8.3beta-798-g528b90 @ /Users/rainerkrug/.emacs.d/org-mode/lisp/)
`----

--8<---------------cut here---------------start------------->8---
#+PROPERTY: header-args :exports both
#+PROPERTY: header-args+ :results output
* The bug
This file create an (possibly endless?) loop during export
* here exports both
#+begin_src R 
cat(13+14)
#+end_src

* and here only code
:PROPERTIES:
:header-args+: exports code
:END:
#+begin_src R 
paste(13+14)
#+end_src
--8<---------------cut here---------------end--------------->8---

Cheers,

Rainer

-- 
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [BUG] on export resulting in endless evaluation
  2015-02-06 10:06 [BUG] on export resulting in endless evaluation Rainer M Krug
@ 2015-02-06 17:50 ` Charles Berry
  2015-02-07 14:46   ` Rainer M Krug
  0 siblings, 1 reply; 7+ messages in thread
From: Charles Berry @ 2015-02-06 17:50 UTC (permalink / raw)
  To: emacs-orgmode

Rainer M Krug <Rainer <at> krugs.de> writes:

> 
> 
> Hi
> 
> when exporting the fillowing org file, I get an endless loop of
> evaluations.
> 
> This happens with only orgmode and languages enabled
> 
> ,----
> | GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, Carbon Version 157
> | Org-mode version 8.3beta (release_8.3beta-798-g528b90  <at>  
> `----
> 
> --8<---------------cut here---------------start------------->8---
> #+PROPERTY: header-args :exports both
> #+PROPERTY: header-args+ :results output
> * The bug
> This file create an (possibly endless?) loop during export
> * here exports both
> #+begin_src R 
> cat(13+14)
> #+end_src
> 
> * and here only code
> :PROPERTIES:
> :header-args+: exports code
> :END:
> #+begin_src R 
> paste(13+14)
> #+end_src
> --8<---------------cut here---------------end--------------->8---
> 

Add this to the end of your example and run the src block:

--8<---------------cut here---------------start------------->8---

#+BEGIN_SRC emacs-lisp :results pp
(org-entry-get (point) "header-args" t)
#+END_SRC

#+RESULTS:
: ":exports both :results output exports code"

--8<---------------cut here---------------end--------------->8---


As you see the property API merely adds the `exports code' to the end of the
 "header-args"value.

Babel then ignores the 'exports' and you end up with `:results output code' 
which creates an executable src block. Since :exports both' is set, that src 
block is executed. And so on.

A bug? 

I guess Babel could do a better job of screening header-args and barf if invalid 
args are submitted. I believe that `org-babel-merge-params' is the place where 
a check could be introduced, but AFAICS there is none such.

Of course `:exports code' solves this, but I think you knew that. :-)

HTH,

Chuck

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [BUG] on export resulting in endless evaluation
  2015-02-06 17:50 ` Charles Berry
@ 2015-02-07 14:46   ` Rainer M Krug
  2015-02-09 11:00     ` Sebastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Rainer M Krug @ 2015-02-07 14:46 UTC (permalink / raw)
  To: Charles Berry; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2554 bytes --]

Charles Berry <ccberry@ucsd.edu> writes:

> Rainer M Krug <Rainer <at> krugs.de> writes:
>
>> 
>> 
>> Hi
>> 
>> when exporting the fillowing org file, I get an endless loop of
>> evaluations.
>> 
>> This happens with only orgmode and languages enabled
>> 
>> ,----
>> | GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, Carbon Version 157
>> | Org-mode version 8.3beta (release_8.3beta-798-g528b90  <at>  
>> `----
>> 
>> --8<---------------cut here---------------start------------->8---
>> #+PROPERTY: header-args :exports both
>> #+PROPERTY: header-args+ :results output
>> * The bug
>> This file create an (possibly endless?) loop during export
>> * here exports both
>> #+begin_src R 
>> cat(13+14)
>> #+end_src
>> 
>> * and here only code
>> :PROPERTIES:
>> :header-args+: exports code
>> :END:
>> #+begin_src R 
>> paste(13+14)
>> #+end_src
>> --8<---------------cut here---------------end--------------->8---
>> 
>
> Add this to the end of your example and run the src block:
>
>
> #+BEGIN_SRC emacs-lisp :results pp
> (org-entry-get (point) "header-args" t)
> #+END_SRC
>
> #+RESULTS:
> : ":exports both :results output exports code"

Very useful function - I think I will use it quite often! I would have
seen the problem immediately - the missing :

>
>
>
> As you see the property API merely adds the `exports code' to the end of the
>  "header-args"value.
>
> Babel then ignores the 'exports'

I assume because it does not know it - which makes sense.

> and you end up with `:results output code' which creates an executable
> src block. Since :exports both' is set, that src block is
> executed. And so on.

OK - I think I understand this logic.

>
> A bug?

Not actually a bug I would say now, but mailny a user error (I did
forget the :...)

>
> I guess Babel could do a better job of screening header-args and barf if invalid 
> args are submitted.

This would be really nice. Also, possibly in the message buffer show the
header-args when a block is executed would make this kind of error more obvious?

> I believe that `org-babel-merge-params' is the place where a check
> could be introduced, but AFAICS there is none such.

There should be at least a warning, if not an error thrown, if an
invalid header argument is passed.

>
> Of course `:exports code' solves this, but I think you knew that. :-)

Now I know...

Thanks,

Rainer

>
> HTH,
>
> Chuck
>
>
>
>
>

-- 
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [BUG] on export resulting in endless evaluation
  2015-02-07 14:46   ` Rainer M Krug
@ 2015-02-09 11:00     ` Sebastien Vauban
  2015-02-09 12:25       ` Rainer M Krug
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2015-02-09 11:00 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Rainer M Krug wrote:
> Charles Berry <ccberry-XkckGZ689+c@public.gmane.org> writes:
>> Rainer M Krug <Rainer <at> krugs.de> writes:
>>> 
>>> when exporting the fillowing org file, I get an endless loop of
>>> evaluations.
>>> 
>>> --8<---------------cut here---------------start------------->8---
>>> #+PROPERTY: header-args :exports both
>>> #+PROPERTY: header-args+ :results output
>>> * The bug
>>> This file create an (possibly endless?) loop during export
>>> * here exports both
>>> #+begin_src R 
>>> cat(13+14)
>>> #+end_src
>>> 
>>> * and here only code
>>> :PROPERTIES:
>>> :header-args+: exports code
>>> :END:
>>> #+begin_src R 
>>> paste(13+14)
>>> #+end_src
>>> --8<---------------cut here---------------end--------------->8---
>>
>> Add this to the end of your example and run the src block:
>>
>> #+BEGIN_SRC emacs-lisp :results pp
>> (org-entry-get (point) "header-args" t)
>> #+END_SRC
>>
>> #+RESULTS:
>> : ":exports both :results output exports code"
>
> Very useful function - I think I will use it quite often! I would have
> seen the problem immediately - the missing :

FWIW, `C-c C-v I' (or `C-c C-v C-I') would show you:

--8<---------------cut here---------------start------------->8---
Lang: R
Header Arguments:
        :cache          no
        :exports        code
        :hlines         no
        :noweb          no
        :results        replace
        :session        none
        :tangle         no
        exports         code
--8<---------------cut here---------------end--------------->8---

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [BUG] on export resulting in endless evaluation
  2015-02-09 11:00     ` Sebastien Vauban
@ 2015-02-09 12:25       ` Rainer M Krug
  2015-02-10  0:44         ` Charles Berry
  0 siblings, 1 reply; 7+ messages in thread
From: Rainer M Krug @ 2015-02-09 12:25 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ

[-- Attachment #1: Type: text/plain, Size: 3975 bytes --]

Sebastien Vauban <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
writes:

> Rainer M Krug wrote:
>> Charles Berry <ccberry-XkckGZ689+c@public.gmane.org> writes:
>>> Rainer M Krug <Rainer <at> krugs.de> writes:
>>>> 
>>>> when exporting the fillowing org file, I get an endless loop of
>>>> evaluations.
>>>> 
>>>> --8<---------------cut here---------------start------------->8---
>>>> #+PROPERTY: header-args :exports both
>>>> #+PROPERTY: header-args+ :results output
>>>> * The bug
>>>> This file create an (possibly endless?) loop during export
>>>> * here exports both
>>>> #+begin_src R 
>>>> cat(13+14)
>>>> #+end_src
>>>> 
>>>> * and here only code
>>>> :PROPERTIES:
>>>> :header-args+: exports code
>>>> :END:
>>>> #+begin_src R 
>>>> paste(13+14)
>>>> #+end_src
>>>> --8<---------------cut here---------------end--------------->8---
>>>
>>> Add this to the end of your example and run the src block:
>>>
>>> #+BEGIN_SRC emacs-lisp :results pp
>>> (org-entry-get (point) "header-args" t)
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> : ":exports both :results output exports code"
>>
>> Very useful function - I think I will use it quite often! I would have
>> seen the problem immediately - the missing :
>
> FWIW, `C-c C-v I' (or `C-c C-v C-I') would show you:

Now this is really helpful.

Brilliant.

Now If I do this in the faulty block, I get:


,----
| Lang: R
| Header Arguments:
| 	:cache		no
| 	:exports	both
| 	:hlines		no
| 	:noweb		no
| 	:results	code exports output replace
| 	:session	none
| 	:tangle		no
`----


And I can see if something is wrong.

One question remains: to debug wrong header arguments, it would be useful to
see, in addition to the resulting header arguments, where they came
from, especially the header-args argument would be useful to see.

So I added the line

--8<---------------cut here---------------start------------->8---
(when header-args     (funcall printf "header-args: %s\n"     header-args))
--8<---------------cut here---------------end--------------->8---

to the output, and was surprised:

Using the second code block in my example, I get (line breaks and bold added for
readability):

,----
| Lang: R
| header-args: ((:comments . ) (:shebang . ) (:cache . no) (:padline . )
| (:noweb . no) (:tangle . no) (:exports . both) (:results . code exports
| output replace) (:hlines . no) (:session . none))
| Header Arguments:
| 	:cache		no
| 	:exports	both
| 	:hlines		no
| 	:noweb		no
| 	:results	code exports output replace
| 	:session	none
| 	:tangle		no
`----

1) I thought that header-args is simply a string, but it already seems
to be a list?

2) Am I right in assuming that when I use header-args, the string passed
is parsed and then either set as header-args or, if using header-args+,
added to the header-args?

3) even when using +, the previously set value *of the header argument* is overwritten?

4) if an invalid string is given, where is it appended? Woulddn't it
make sense to only accept values of the pattern =:headerArgument string=
to avoid these kind of user errors?

5) Is there any way in getting, in this function, the same output
(header-args) as from the code block suggested by Charles:


--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC emacs-lisp :results pp
(org-entry-get (point) "header-args" t)
#+END_SRC

#+RESULTS:
: ":exports both :results output exports code"
--8<---------------cut here---------------end--------------->8---

Thanks,

Rainer


>
> Lang: R
> Header Arguments:
>         :cache          no
>         :exports        code
>         :hlines         no
>         :noweb          no
>         :results        replace
>         :session        none
>         :tangle         no
>         exports         code
>
> Best regards,
>   Seb

-- 
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [BUG] on export resulting in endless evaluation
  2015-02-09 12:25       ` Rainer M Krug
@ 2015-02-10  0:44         ` Charles Berry
  2015-02-10  8:25           ` Rainer M Krug
  0 siblings, 1 reply; 7+ messages in thread
From: Charles Berry @ 2015-02-10  0:44 UTC (permalink / raw)
  To: emacs-orgmode

Rainer M Krug <Rainer <at> krugs.de> writes:

> 
> Sebastien Vauban <sva-news@...>
> writes:
> 
> > Rainer M Krug wrote:
> >> Charles Berry <ccberry@...> writes:
> >>> Rainer M Krug <Rainer <at> krugs.de> writes:
> >>>> 
> >>>> when exporting the fillowing org file, I get an endless loop of
> >>>> evaluations.
> >>>> 
> >>>> --8<---------------cut here---------------start------------->8---
> >>>> #+PROPERTY: header-args :exports both
> >>>> #+PROPERTY: header-args+ :results output
> >>>> * The bug
> >>>> This file create an (possibly endless?) loop during export
> >>>> * here exports both
> >>>> #+begin_src R 
> >>>> cat(13+14)
> >>>> #+end_src
> >>>> 
> >>>> * and here only code
> >>>> :PROPERTIES:
> >>>> :header-args+: exports code
> >>>> :END:
> >>>> #+begin_src R 
> >>>> paste(13+14)
> >>>> #+end_src
> >>>> --8<---------------cut here---------------end--------------->8---
> >>>

[discussion of problem, diagnostic methods, and cures deleted]


> 1) I thought that header-args is simply a string, but it already seems
> to be a list?

Depends on which `header-args' one is discussing:

1. A property, as in `(org-entry-get (point) "header-args" t)'

2. The value of `(nth 2 (org-babel-get-src-block-info))'

3. The value of an elisp variable like `org-babel-default-header-args'

4. The 4th string matched by `org-babel-src-block-regexp' 

5. The first string matched by `org-babel-multi-line-header-regexp'

1, 4 and 5 are strings. 2 and 3 are lists.

> 
[more questions deleted]
> 

Exactly what happens and when is a long story, involving a bunch of 
functions.

You might start by reading `org-babel-get-src-block-info' and 
`org-babel-merge-params'.

I think most of what you need to know really is in 

   (info "(org) Using header arguments")
and
   (info "(org) Property syntax")

Just remember that a property called `header-args' is a string until Babel 
starts working on it.


> 5) Is there any way in getting, in this function, the same output
> (header-args) as from the code block suggested by Charles:
> 

You might try

#+BEGIN_SRC emacs-lisp :results pp
   (cons (org-entry-get (point) "header-args" t)
         (nth 2 (org-babel-get-src-block-info)))
#+END_SRC

HTH,

Chuck

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [BUG] on export resulting in endless evaluation
  2015-02-10  0:44         ` Charles Berry
@ 2015-02-10  8:25           ` Rainer M Krug
  0 siblings, 0 replies; 7+ messages in thread
From: Rainer M Krug @ 2015-02-10  8:25 UTC (permalink / raw)
  To: Charles Berry; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3026 bytes --]

Charles Berry <ccberry@ucsd.edu> writes:

> Rainer M Krug <Rainer <at> krugs.de> writes:
>
>> 
>> Sebastien Vauban <sva-news@...>
>> writes:
>> 
>> > Rainer M Krug wrote:
>> >> Charles Berry <ccberry@...> writes:
>> >>> Rainer M Krug <Rainer <at> krugs.de> writes:
>> >>>> 
>> >>>> when exporting the fillowing org file, I get an endless loop of
>> >>>> evaluations.
>> >>>> 
>> >>>> --8<---------------cut here---------------start------------->8---
>> >>>> #+PROPERTY: header-args :exports both
>> >>>> #+PROPERTY: header-args+ :results output
>> >>>> * The bug
>> >>>> This file create an (possibly endless?) loop during export
>> >>>> * here exports both
>> >>>> #+begin_src R 
>> >>>> cat(13+14)
>> >>>> #+end_src
>> >>>> 
>> >>>> * and here only code
>> >>>> :PROPERTIES:
>> >>>> :header-args+: exports code
>> >>>> :END:
>> >>>> #+begin_src R 
>> >>>> paste(13+14)
>> >>>> #+end_src
>> >>>> --8<---------------cut here---------------end--------------->8---
>> >>>
>
> [discussion of problem, diagnostic methods, and cures deleted]
>
>
>> 1) I thought that header-args is simply a string, but it already seems
>> to be a list?
>
> Depends on which `header-args' one is discussing:
>
> 1. A property, as in `(org-entry-get (point) "header-args" t)'
>
> 2. The value of `(nth 2 (org-babel-get-src-block-info))'
>
> 3. The value of an elisp variable like `org-babel-default-header-args'
>
> 4. The 4th string matched by `org-babel-src-block-regexp' 
>
> 5. The first string matched by `org-babel-multi-line-header-regexp'
>
> 1, 4 and 5 are strings. 2 and 3 are lists.

Wow - there are many...

But this helps quite a bit.

>
>> 
> [more questions deleted]
>> 
>
> Exactly what happens and when is a long story, involving a bunch of 
> functions.
>
> You might start by reading `org-babel-get-src-block-info' and 
> `org-babel-merge-params'.
>
> I think most of what you need to know really is in 
>
>    (info "(org) Using header arguments")
> and
>    (info "(org) Property syntax")
>
> Just remember that a property called `header-args' is a string until Babel 
> starts working on it.

So your original code, returns the "property called 'header-args'",
(1) while your function below returns the one from 2) above. That
clarifies.

>
>
>> 5) Is there any way in getting, in this function, the same output
>> (header-args) as from the code block suggested by Charles:
>> 
>
> You might try

Thanks - but I was thinking about the ot=her way round, how I could get
the "property called 'header-args'" (1) within the function called when
using C-c C-v C-i to help in debugging - found a way of doing it and
will send a patch.

> #+BEGIN_SRC emacs-lisp :results pp
>    (cons (org-entry-get (point) "header-args" t)
>          (nth 2 (org-babel-get-src-block-info)))
> #+END_SRC
>
> HTH,

Most definitely,

Thanks,

Rainer

>
> Chuck
>
>
>

-- 
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-02-10  8:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 10:06 [BUG] on export resulting in endless evaluation Rainer M Krug
2015-02-06 17:50 ` Charles Berry
2015-02-07 14:46   ` Rainer M Krug
2015-02-09 11:00     ` Sebastien Vauban
2015-02-09 12:25       ` Rainer M Krug
2015-02-10  0:44         ` Charles Berry
2015-02-10  8:25           ` Rainer M Krug

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).