From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Neff Subject: [babel] - Support for Groovy Date: Fri, 19 Mar 2010 12:46:33 -0500 Message-ID: <211769421003191046x18b4ae74u888c59053462b72c@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1037733900==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsgHP-0000wP-0O for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 13:46:39 -0400 Received: from [140.186.70.92] (port=48515 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsgHN-0000uB-J7 for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 13:46:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NsgHM-0006u0-35 for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 13:46:37 -0400 Received: from mail-gy0-f169.google.com ([209.85.160.169]:51229) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NsgHL-0006tX-VG for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 13:46:36 -0400 Received: by gyb13 with SMTP id 13so3059463gyb.0 for ; Fri, 19 Mar 2010 10:46:34 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --===============1037733900== Content-Type: multipart/alternative; boundary=000e0cd705d297978f04822aed84 --000e0cd705d297978f04822aed84 Content-Type: text/plain; charset=ISO-8859-1 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 blah blah blah) I suspect that this is because I don't have a major-mode for Groovy installed. 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 --000e0cd705d297978f04822aed84 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 decid= ed 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
=A0=A0 println "bar"; #+end_src

However, the program doesn't run -- all I get is the &= quot;usage" output from Groovy:
=A0 (Ex: usage:=A0 groovy <file&= gt; blah blah blah)

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

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 any= one help?=A0 I have the source code here:

http://github.com/NathanNeff/org-mode/blob/nate/contrib/babel/lisp/lang= s/org-babel-groovy.el

Thanks,
--Nate
--000e0cd705d297978f04822aed84-- --===============1037733900== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1037733900==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [babel] - Support for Groovy Date: Fri, 19 Mar 2010 14:50:09 -0400 Message-ID: <87mxy4rvry.fsf@stats.ox.ac.uk> References: <211769421003191046x18b4ae74u888c59053462b72c@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NshH2-0000Ax-AL for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:50:20 -0400 Received: from [140.186.70.92] (port=50016 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NshH0-00008O-No for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:50:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NshGz-0006El-1v for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:50:18 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:63602) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NshGy-0006EJ-QP for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:50:16 -0400 In-Reply-To: <211769421003191046x18b4ae74u888c59053462b72c@mail.gmail.com> (Nathan Neff's message of "Fri, 19 Mar 2010 12:46:33 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nathan Neff Cc: emacs-orgmode@gnu.org Nathan Neff 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 > =C2=A0=C2=A0 println "bar"; > #+end_src > > However, the program doesn't run -- all I get is the "usage" output from > Groovy: > =C2=A0 (Ex: usage:=C2=A0 groovy blah blah blah) > Hi Nate, > I suspect that this is because I don't have a major-mode for Groovy insta= lled. 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 fai= led, 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" 'curren= t-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 fo= r the > output > to be inserted into an org-babel file. > > Can anyone help?=C2=A0 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: [babel] - Support for Groovy Date: Fri, 19 Mar 2010 18:55:15 +0000 Message-ID: <87ljdop2ek.wl%ucecesf@ucl.ac.uk> References: <211769421003191046x18b4ae74u888c59053462b72c@mail.gmail.com> <87mxy4rvry.fsf@stats.ox.ac.uk> Reply-To: e.fraga@ucl.ac.uk Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NshLx-0003jm-JK for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:55:25 -0400 Received: from [140.186.70.92] (port=56458 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NshLw-0003iV-6m for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:55:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NshLu-0006sL-9o for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:55:24 -0400 Received: from vscane-b.ucl.ac.uk ([144.82.108.141]:43240) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NshLu-0006sC-4t for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 14:55:22 -0400 In-Reply-To: <87mxy4rvry.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs-orgmode@gnu.org On Fri, 19 Mar 2010 14:50:09 -0400, Dan Davison wr= ote: >=20 > Nathan Neff writes: >=20 > > 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. [...] > > =C2=A0 (Ex: usage:=C2=A0 groovy blah blah blah) > > >=20 > Hi Nate, >=20 > > I suspect that this is because I don't have a major-mode for Groovy ins= talled. >=20 > 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... From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [babel] - Support for Groovy Date: Fri, 19 Mar 2010 15:29:02 -0400 Message-ID: <87eijgrtz5.fsf@stats.ox.ac.uk> References: <211769421003191046x18b4ae74u888c59053462b72c@mail.gmail.com> <87mxy4rvry.fsf@stats.ox.ac.uk> <87ljdop2ek.wl%ucecesf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nshsc-0000ia-Pm for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 15:29:10 -0400 Received: from [140.186.70.92] (port=38805 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nshsb-0000gF-A1 for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 15:29:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NshsZ-0001mi-6f for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 15:29:08 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:40391) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NshsY-0001mH-Tl for emacs-orgmode@gnu.org; Fri, 19 Mar 2010 15:29:07 -0400 In-Reply-To: <87ljdop2ek.wl%ucecesf@ucl.ac.uk> (Eric S. Fraga's message of "Fri, 19 Mar 2010 18:55:15 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: e.fraga@ucl.ac.uk Cc: emacs-orgmode@gnu.org Eric S Fraga writes: > On Fri, 19 Mar 2010 14:50:09 -0400, Dan Davison = wrote: >>=20 >> Nathan Neff writes: >>=20 >> > 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. > > [...] > >> > =C2=A0 (Ex: usage:=C2=A0 groovy blah blah blah) >> > >>=20 >> Hi Nate, >>=20 >> > I suspect that this is because I don't have a major-mode for Groovy in= stalled. >>=20 >> 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=3D%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