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 15:29:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Eric S Fraga <address@hidden> writes:

> On Fri, 19 Mar 2010 14:50:09 -0400, Dan Davison <address@hidden> wrote:
>> 
>> Nathan Neff <address@hidden> 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 via email to

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