emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org-babel -- Improper syntax error in session mode?


From: Herbert Sitz
Subject: Re: [O] org-babel -- Improper syntax error in session mode?
Date: Mon, 20 Jun 2011 17:27:39 -0700

On Mon, Jun 20, 2011 at 5:08 PM, Nick Dokos <address@hidden> wrote:
> Herbert Sitz <address@hidden> wrote:
>
>> ... (and, it turns out, _avoid_ blank lines in other cases)
>
> What are those cases?
>
> Nick
>

_Every_ spot where a blank line occurs that is followed by
"unindented" line of (uncommented) code.  By design, the blank line in
interactive shell terminates a "highest-level" block and triggers its
output.  So you _can't_ have blank lines within a level-1 block, all
lines in the block must have text.  I just noticed, though, that you
can include comments and that the indent of comments is irrelevant, so
these blank lines could merely have a '# sign prepended to them to
transform them into comments.  (Existence of "unindented" comments
needs to be taken into account for the regex that adds blank lines,
though, since they're to be ignored for that purpose.)

So this works fine in interactive shell with Eric's patch:
--------------------------------------
#+begin_src python :results output :session mypy
    x = 1
    y = 1
    z = 1
    for i in range(1,2):
        x = x + i
        print x
    # comment here
        for y in range(10,11):
            print y
    # comment here
        for z in range(5,6):
            print z
            while y > 0:
                print y
                y=y-1

    print "Did it work?"
#+end_src
-------------------------------------

but this doesn't
-----------------------------
#+begin_src python :results output :session mypy
    x = 1
    y = 1
    z = 1
    for i in range(1,2):
        x = x + i
        print x

        for y in range(10,11):
            print y

        for z in range(5,6):
            print z
            while y > 0:
                print y
                y=y-1

    print "Did it work?"
#+end_src
------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]