emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: e.fraga@ucl.ac.uk
Cc: emacs-orgmode@gnu.org
Subject: Re: [babel] - Support for Groovy
Date: Fri, 19 Mar 2010 15:29:02 -0400	[thread overview]
Message-ID: <87eijgrtz5.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <87ljdop2ek.wl%ucecesf@ucl.ac.uk> (Eric S. Fraga's message of "Fri, 19 Mar 2010 18:55:15 +0000")

Eric S Fraga <ucecesf@ucl.ac.uk> writes:

> On Fri, 19 Mar 2010 14:50:09 -0400, Dan Davison <davison@stats.ox.ac.uk> wrote:
>> 
>> Nathan Neff <nathan.neff@gmail.com> writes:
>> 
>> > 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.
>
> [...]
>
>> >   (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:
>
> Can you not simply put the commands into a file and then run groovy on
> that given that groovy obviously expects a file (see usage above)?  I
> believe that's what you have done with some of the other babel
> languages?  It's what I did for my own very clumsy and limited maxima
> and octave interfaces...

We could, but I had recently settled on a consistent approach using
shell-command-on-region across languages. The main thing is that this
works straightforwardly with tramp when code is executing on a remote
machine, plus we have a consistent way of dealing with stderr and
stdout. But then, isn't there something about consistency and hobgoblins
and small minds. So yes, if groovy can't take commands on stdin then
this seems to work:

(defun org-babel-groovy-evaluate (session body &optional result-type)
  "Evaluate groovy code in BODY"
  ;; external process evaluation
  (let ((infile (make-temp-file "org_babel_groovy_input_")))
    (save-excursion
      (with-temp-buffer
	(with-temp-file infile (insert body))
	;; (message "buffer=%s" (buffer-string)) ;; debugging
	(shell-command (format "groovy %s" infile) (current-buffer))
	(buffer-string)))))

Nate -- if you haven't then could you sign FSF copyright papers for
Emacs, so we can add your module?

Eric -- would you your maxima (and jython) code to go in org-babel? (We'd
like it)

Dan

      reply	other threads:[~2010-03-19 19:29 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
2010-03-19 18:55   ` Eric S Fraga
2010-03-19 19:29     ` Dan Davison [this message]

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=87eijgrtz5.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    /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).