emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: Nathan Neff <nathan.neff@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [babel] - Support for Groovy
Date: Fri, 19 Mar 2010 14:50:09 -0400	[thread overview]
Message-ID: <87mxy4rvry.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <211769421003191046x18b4ae74u888c59053462b72c@mail.gmail.com> (Nathan Neff's message of "Fri, 19 Mar 2010 12:46:33 -0500")

Nathan Neff <nathan.neff@gmail.com> 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.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2010-03-19 18:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-19 17:46 [babel] - Support for Groovy Nathan Neff
2010-03-19 18:50 ` Dan Davison [this message]
2010-03-19 18:55   ` Eric S Fraga
2010-03-19 19:29     ` Dan Davison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mxy4rvry.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=nathan.neff@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).