emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] [babel] - Support for Groovy


From: Dan Davison
Subject: Re: [Orgmode] [babel] - Support for Groovy
Date: Fri, 19 Mar 2010 14:50:09 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Nathan Neff <address@hidden> writes:

> Hello,
>
> I'm trying to write an org-babel-groovy.el file, and have read through the
> org-babel-template.el and org-babel-template.org files.
>
> Eventually, I decided to just copy the org-babel-perl.el file to
> org-babel-groovy and
> replace 'perl' with 'groovy' where appropriate :-/
>
> I'm able to get Groovy to run from an org-babel file with this code:
>
> #+begin_src groovy :results output
>    println "bar";
> #+end_src
>
> However, the program doesn't run -- all I get is the "usage" output from
> Groovy:
>   (Ex: usage:  groovy <file> blah blah blah)
>

Hi Nate,

> I suspect that this is because I don't have a major-mode for Groovy installed.

No, that's not the problem. This should be easy to fix... we just need
to know how to get groovy to read commands from standard input. I.e. how
do we do the groovy equivalent of this:

~> echo 'print "bar\n"' | perl
bar

I haven't figured it out yet. Typically one would use a '-' to represent
stdin on the command line. My most promising attempt was this

~> echo 'println "bar";' | groovy -e -
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, 
script_from_command_line: 1: unexpected token:  @ line 1, column 2.
1 error

'script_from_command_line' sounded good there.

 These don't work

~> echo 'println "bar";' | groovy
error: neither -e or filename provided
[usage message follows]

~> echo 'println "bar";' | groovy -
error: neither -e or filename provided
[usage message follows]

So if you work out how to do that, then on line 96 of
org-babel-groovy.el

(org-babel-shell-command-on-region (point-min) (point-max) "groovy" 
'current-buffer 'replace)

change "groovy" to whatever the correct shell invocation for reading
commands from stdin is. There are other solutions (e.g. writing the
commands to file, or writing a wrapper script) but it would be
preferable not to have to take those routes.

Dan






>
> I'd really just like for a Groovy script to be run from org-babel, and for the
> output
> to be inserted into an org-babel file.
>
> Can anyone help?  I have the source code here:
>
> http://github.com/NathanNeff/org-mode/blob/nate/contrib/babel/lisp/langs/
> org-babel-groovy.el
>
> Thanks,
> --Nate
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode




reply via email to

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