* [BUG] org-babel-perl and formats
@ 2010-04-08 0:22 Łukasz Stelmach
2010-04-08 15:50 ` Dan Davison
0 siblings, 1 reply; 5+ messages in thread
From: Łukasz Stelmach @ 2010-04-08 0:22 UTC (permalink / raw)
To: emacs-orgmode
Hello.
I am not sure I will be able to spend some time on this so I'll share my
observation with you. org-babel-perl can't cope with perl formats, with
their endings to be precise. A format is defined by:
format FORMAT_NAME =
body of the format
.
The problem is that formats *must* and with a single solitary dot or, to
be precise "\n.\n" sequence. org-babel-perl doesn't care about it and
puts "\t" befor the dot.
Are these indents really necessary in the text
that goes straight through IPC pipes of our OS of choice?
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] org-babel-perl and formats
2010-04-08 0:22 [BUG] org-babel-perl and formats Łukasz Stelmach
@ 2010-04-08 15:50 ` Dan Davison
2010-04-09 9:11 ` Łukasz Stelmach
0 siblings, 1 reply; 5+ messages in thread
From: Dan Davison @ 2010-04-08 15:50 UTC (permalink / raw)
To: Łukasz Stelmach; +Cc: emacs-orgmode
Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
> Hello.
>
> I am not sure I will be able to spend some time on this so I'll share my
> observation with you. org-babel-perl can't cope with perl formats, with
> their endings to be precise. A format is defined by:
>
> format FORMAT_NAME =
> body of the format
> .
>
> The problem is that formats *must* and with a single solitary dot or, to
> be precise "\n.\n" sequence. org-babel-perl doesn't care about it and
> puts "\t" befor the dot.
Hi Łukasz,
Could you post an example? I don't believe we insert tab
characters. I've never used a perl format before, but I just tried it
and it seemed to work OK with C-c C-c:
--8<---------------cut here---------------start------------->8---
#+begin_src perl
format STDOUT =
@<<<<<< @|||||| @>>>>>>
"left", "middle", "right"
.
write ;
#+end_src
#+results:
: left middle right
--8<---------------cut here---------------end--------------->8---
Incidentally, do you know the variable org-src-preserve-indentation?
When I first read your email I thought that would be the answer. In fact
it doesn't seem to be relevant, but I thought I would mention it anyway.
Dan
>
> Are these indents really necessary in the text
> that goes straight through IPC pipes of our OS of choice?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] org-babel-perl and formats
2010-04-08 15:50 ` Dan Davison
@ 2010-04-09 9:11 ` Łukasz Stelmach
2010-04-09 13:21 ` Dan Davison
0 siblings, 1 reply; 5+ messages in thread
From: Łukasz Stelmach @ 2010-04-09 9:11 UTC (permalink / raw)
To: emacs-orgmode
Dan Davison <davison@stats.ox.ac.uk> writes:
> Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
>> I am not sure I will be able to spend some time on this so I'll share my
>> observation with you. org-babel-perl can't cope with perl formats, with
>> their endings to be precise. A format is defined by:
>>
>> format FORMAT_NAME =
>> body of the format
>> .
>>
>> The problem is that formats *must* and with a single solitary dot or, to
>> be precise "\n.\n" sequence. org-babel-perl doesn't care about it and
>> puts "\t" befor the dot.
>
> Could you post an example? I don't believe we insert tab
> characters. I've never used a perl format before, but I just tried it
> and it seemed to work OK with C-c C-c:
>
> #+begin_src perl
> format STDOUT =
> @<<<<<< @|||||| @>>>>>>
> "left", "middle", "right"
> .
> write ;
> #+end_src
>
> #+results:
> : left middle right
With the very same code i get
--8<---------------cut here---------------start------------->8---
Format not terminated at - line 11, at end of line
syntax error at - line 11, at EOF
Execution of - aborted due to compilation errors.
--8<---------------cut here---------------end--------------->8---
while strace shows the code being wrapped
write(9, "\nsub main {\n\tformat STDOUT =\n\t@<<<<<< @|||||| @>>>>>>\n\t\"left\", \"middle\", \"right\"\n\t.\n\twrite ;\n}\n@r = main;\nopen(o, \">/tmp/perl-functional-results17170oCG\");\nprint o join(\"\\n\", @r), \"\\n\"", 184) = 184
inside something really odd:
--8<---------------cut here---------------start------------->8---
sub main {
format STDOUT =
@<<<<<< @|||||| @>>>>>>
"left", "middle", "right"
.
write ;
}
@r = main;
open(o, ">/tmp/perl-functional-results17170oCG");
print o join("\n", @r), "\n"
--8<---------------cut here---------------end--------------->8---
> Incidentally, do you know the variable org-src-preserve-indentation?
> When I first read your email I thought that would be the answer. In fact
> it doesn't seem to be relevant, but I thought I would mention it anyway.
Unfortunately it doesn't make any difference.
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [BUG] org-babel-perl and formats
2010-04-09 9:11 ` Łukasz Stelmach
@ 2010-04-09 13:21 ` Dan Davison
2010-04-09 20:53 ` Łukasz Stelmach
0 siblings, 1 reply; 5+ messages in thread
From: Dan Davison @ 2010-04-09 13:21 UTC (permalink / raw)
To: Łukasz Stelmach; +Cc: emacs-orgmode
Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
> Dan Davison <davison@stats.ox.ac.uk> writes:
>
>> Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
>>> I am not sure I will be able to spend some time on this so I'll share my
>>> observation with you. org-babel-perl can't cope with perl formats, with
>>> their endings to be precise. A format is defined by:
>>>
>>> format FORMAT_NAME =
>>> body of the format
>>> .
>>>
>>> The problem is that formats *must* and with a single solitary dot or, to
>>> be precise "\n.\n" sequence. org-babel-perl doesn't care about it and
>>> puts "\t" befor the dot.
>>
>> Could you post an example? I don't believe we insert tab
>> characters. I've never used a perl format before, but I just tried it
>> and it seemed to work OK with C-c C-c:
>>
>> #+begin_src perl
>> format STDOUT =
>> @<<<<<< @|||||| @>>>>>>
>> "left", "middle", "right"
>> .
>> write ;
>> #+end_src
>>
>> #+results:
>> : left middle right
>
> With the very same code i get
>
> Format not terminated at - line 11, at end of line
> syntax error at - line 11, at EOF
> Execution of - aborted due to compilation errors.
Oops. Sorry Łukasz, my mistake.
You are of course right, we were adding indentation to perl code
(apparently I started with a copy of org-babel-python.el when I wrote
org-babel-perl.el). That is fixed now.
We got different results because I had set perl to :results output by
default. For this particular block, you will also want to use
:results output (see below).
You pointed out that
>
> while strace shows the code being wrapped
>
> write(9, "\nsub main {\n\tformat STDOUT =\n\t@<<<<<< @|||||| @>>>>>>\n\t\"left\", \"middle\", \"right\"\n\t.\n\twrite ;\n}\n@r = main;\nopen(o, \">/tmp/perl-functional-results17170oCG\");\nprint o join(\"\\n\", @r), \"\\n\"", 184) = 184
>
> inside something really odd:
>
> sub main {
> format STDOUT =
> @<<<<<< @|||||| @>>>>>>
> "left", "middle", "right"
> .
> write ;
> }
> @r = main;
> open(o, ">/tmp/perl-functional-results17170oCG");
> print o join("\n", @r), "\n"
Babel has two basic modes of execution:
:results value :: The default, you get the value of the last expression, interpreted as a list/table if possible.
:results output :: You get stdout
The wrapping-in-function-body stuff only happens with :results value.
So by default, with the block above, you will get the counterintuitive outcome:
#+results:
| 1 |
| 1 |
The default outcome here is fairly baffling, and I imagine that perl
users are often going to want the contents of stdout. This can be done
globally with
(setq org-babel-default-header-args:perl '((:results . "output")))
The trouble with that is that perl blocks will not communicate nicely
with other blocks:
#+source: a-number
#+begin_src perl :results value
4
#+end_src
#+begin_src emacs-lisp :var i=a-number()
(+ i 1)
#+end_src
#+results:
: 5
With :results output on the perl block, we get a
Wrong type argument: number-or-marker-p, ""
because the perl block returns textual output rather than interpreting
the result as numeric.
Dan
>
>> Incidentally, do you know the variable org-src-preserve-indentation?
>> When I first read your email I thought that would be the answer. In fact
>> it doesn't seem to be relevant, but I thought I would mention it anyway.
>
> Unfortunately it doesn't make any difference.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] org-babel-perl and formats
2010-04-09 13:21 ` Dan Davison
@ 2010-04-09 20:53 ` Łukasz Stelmach
0 siblings, 0 replies; 5+ messages in thread
From: Łukasz Stelmach @ 2010-04-09 20:53 UTC (permalink / raw)
To: emacs-orgmode
Dan Davison <davison@stats.ox.ac.uk> writes:
> Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
>
[...]
>> Format not terminated at - line 11, at end of line
>> syntax error at - line 11, at EOF
>> Execution of - aborted due to compilation errors.
>
> Oops. Sorry Łukasz, my mistake.
>
> You are of course right, we were adding indentation to perl code
Arrrr! ;-)
> Babel has two basic modes of execution:
> :results value :: The default, you get the value of the last expression, interpreted as a list/table if possible.
> :results output :: You get stdout
[...]
> (setq org-babel-default-header-args:perl '((:results . "output")))
>
> The trouble with that is that perl blocks will not communicate nicely
> with other blocks:
[...]
Thanks for the warning. It'd probably took me quite some time to
investigate all those details.
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-04-09 20:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-08 0:22 [BUG] org-babel-perl and formats Łukasz Stelmach
2010-04-08 15:50 ` Dan Davison
2010-04-09 9:11 ` Łukasz Stelmach
2010-04-09 13:21 ` Dan Davison
2010-04-09 20:53 ` Łukasz Stelmach
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.