Re: [O] Contribution: ob-groovy.el

2014-03-17 Thread Bastien
Hi Miro,

Miro Bezjak  writes:

> it took a while, but my FSF papers finally pulled through. I guess
> that means ob-groovy.el can now move from `contrib' and into `lisp'.

http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=4d32b9eb

yes, I received the FSF confirmation and moved ob-groovy.el
a few days ago.

Thanks!

-- 
 Bastien



Re: [O] Contribution: ob-groovy.el

2014-03-17 Thread Miro Bezjak
Hi all,

it took a while, but my FSF papers finally pulled through. I guess that
means ob-groovy.el can now move from `contrib' and into `lisp'.

Kind Regards,
Miro



On Mon, Dec 30, 2013 at 3:53 AM, Eric Schulte wrote:

> Miro Bezjak  writes:
>
> > Sure - attached.
> >
>
> Applied, Thanks!
>
> --
> Eric Schulte
> https://cs.unm.edu/~eschulte
> PGP: 0x614CA05D
>


Re: [O] Contribution: ob-groovy.el

2013-12-29 Thread Eric Schulte
Miro Bezjak  writes:

> Sure - attached.
>

Applied, Thanks!

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] Contribution: ob-groovy.el

2013-12-28 Thread Miro Bezjak
Sure - attached.

Kind Regards,
Miro Bezjak


On Sat, Dec 28, 2013 at 5:12 PM, Eric Schulte wrote:

> Hi Miro, Thanks for this contribution!
>
> t...@tsdye.com (Thomas S. Dye) writes:
>
> > Aloha Miro,
> >
> > Miro Bezjak  writes:
> >
> >> can I do all those tasks over the couple of days - when I have more
> time?
> >
> > Yes, of course. The FSF papers will probably take several weeks to
> > complete, if you haven't already done so.
> >
>
> The FSF papers will be required before we can add this to Org-mode
> proper.  In the mean time I'd be happy to add this to contrib.  Could
> you send a patch adding ob-groovy.el to contrib/lisp/ formatted with
> "git format-patch".
>
> Thanks again,
>
> --
> Eric Schulte
> https://cs.unm.edu/~eschulte
> PGP: 0x614CA05D
>
From 6e9cc90e9488257b547ae659676875e171a12820 Mon Sep 17 00:00:00 2001
From: Miro Bezjak 
Date: Sun, 29 Dec 2013 00:39:05 +0100
Subject: [PATCH] contrib/lisp/ob-groovy.el: Add org-babel functions for groovy
 evaluation

---
 contrib/lisp/ob-groovy.el | 120 ++
 1 file changed, 120 insertions(+)
 create mode 100644 contrib/lisp/ob-groovy.el

diff --git a/contrib/lisp/ob-groovy.el b/contrib/lisp/ob-groovy.el
new file mode 100644
index 000..9bb17e6
--- /dev/null
+++ b/contrib/lisp/ob-groovy.el
@@ -0,0 +1,120 @@
+;;; ob-groovy.el --- org-babel functions for Groovy evaluation
+
+;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
+
+;; Author: Miro Bezjak
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see .
+
+;;; Commentary:
+;; Currently only supports the external execution.  No session support yet.
+
+;;; Requirements:
+;; - Groovy language :: http://groovy.codehaus.org
+;; - Groovy major mode :: Can be installed from MELPA or
+;;   https://github.com/russel/Emacs-Groovy-Mode
+
+;;; Code:
+(require 'ob)
+(eval-when-compile (require 'cl))
+
+(defvar org-babel-tangle-lang-exts) ;; Autoloaded
+(add-to-list 'org-babel-tangle-lang-exts '("groovy" . "groovy"))
+(defvar org-babel-default-header-args:groovy '())
+(defvar org-babel-groovy-command "groovy"
+  "Name of the command to use for executing Groovy code.")
+
+(defun org-babel-execute:groovy (body params)
+  "Execute a block of Groovy code with org-babel.  This function is
+called by `org-babel-execute-src-block'"
+  (message "executing Groovy source code block")
+  (let* ((processed-params (org-babel-process-params params))
+ (session (org-babel-groovy-initiate-session (nth 0 processed-params)))
+ (vars (nth 1 processed-params))
+ (result-params (nth 2 processed-params))
+ (result-type (cdr (assoc :result-type params)))
+ (full-body (org-babel-expand-body:generic
+ body params))
+ (result (org-babel-groovy-evaluate
+  session full-body result-type result-params)))
+
+(org-babel-reassemble-table
+ result
+ (org-babel-pick-name
+  (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+ (org-babel-pick-name
+  (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))
+
+
+(defun org-babel-groovy-table-or-string (results)
+  "Convert RESULTS into an appropriate elisp value.
+If RESULTS look like a table, then convert them into an
+Emacs-lisp table, otherwise return the results as a string."
+  (org-babel-script-escape results))
+
+
+(defvar org-babel-groovy-wrapper-method
+
+  "class Runner extends Script {
+def out = new PrintWriter(new ByteArrayOutputStream())
+def run() { %s }
+}
+
+println(new Runner().run())
+")
+
+
+(defun org-babel-groovy-evaluate
+  (session body &optional result-type result-params)
+  "Evaluate BODY in external Groovy process.
+If RESULT-TYPE equals 'output then return standard output as a string.
+If RESULT-TYPE equals 'value then return the value of the last statement
+in BODY as elisp."
+  (when session (error "Sessions are not (yet) supported for Groovy"))
+  (case result-type
+(output
+ (let ((src-file (org-babel-temp-file "groovy-")))
+   (progn (with-temp-file src-file (insert body))
+  (org-babel-eval
+   (concat org-babel-groovy-command " " src-file) ""
+(value
+ (let* ((src-file (org-babel-temp-file "groovy-"))
+(w

Re: [O] Contribution: ob-groovy.el

2013-12-28 Thread Eric Schulte
Hi Miro, Thanks for this contribution!

t...@tsdye.com (Thomas S. Dye) writes:

> Aloha Miro,
>
> Miro Bezjak  writes:
>
>> can I do all those tasks over the couple of days - when I have more time?
>
> Yes, of course. The FSF papers will probably take several weeks to
> complete, if you haven't already done so. 
>

The FSF papers will be required before we can add this to Org-mode
proper.  In the mean time I'd be happy to add this to contrib.  Could
you send a patch adding ob-groovy.el to contrib/lisp/ formatted with
"git format-patch".

Thanks again,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] Contribution: ob-groovy.el

2013-12-27 Thread Thomas S. Dye
Aloha Miro,

Miro Bezjak  writes:

> can I do all those tasks over the couple of days - when I have more time?

Yes, of course. The FSF papers will probably take several weeks to
complete, if you haven't already done so. 

>
> Should I just add the documentation before ob-groovy.el is accepted?
>

I don't see any problem with adding the documentation at your
convenience. Eric Schulte will review ob-groovy.el and work with you to
find its appropriate place in Org mode. I'll be happy to review and edit
the documentation, if you'd like.

> For now, I've updated languages to include scala.
> http://orgmode.org/worg/org-contrib/babel/languages.html

Thanks! I'll take this off my TODO list.

All the best,
Tom

-- 
T.S. Dye & Colleagues, Archaeologists
735 Bishop St, Suite 315, Honolulu, HI 96813
Tel: 808-529-0866, Fax: 808-529-0884
http://www.tsdye.com



Re: [O] Contribution: ob-groovy.el

2013-12-27 Thread Miro Bezjak
Hi Thomas,

can I do all those tasks over the couple of days - when I have more time?

Should I just add the documentation before ob-groovy.el is accepted?

For now, I've updated languages to include scala.
http://orgmode.org/worg/org-contrib/babel/languages.html

Kind Regards,
Miro


On Fri, Dec 27, 2013 at 1:08 AM, Thomas S. Dye  wrote:

> Aloha Miro,
>
> Thanks for your contribution to Org mode.
>
> Have you signed the FSF papers so that ob-groovy.el can be added to Org
> mode?  See:
> http://orgmode.org/worg/org-contribute.html#sec-6
>
> Contributions by authors who have not signed the FSF papers are
> typically added to the contrib directory and are not distributed with
> Emacs.
>
> Also, are you willing to draft documentation?  For a link to a
> documentation template, see:
> http://orgmode.org/worg/org-contrib/babel/languages.html
>
> I was going to suggest that you use the Scala documentation as a guide,
> but it doesn't exist! In fact, Scala doesn't appear in Worg's list of
> languages supported by Babel.  One of those days ...
>
> Thanks again for your contribution.
>
> All the best,
> Tom
>
> Miro Bezjak  writes:
>
> > Hi all,
> >
> > I would like to contribute org-babel functions for Groovy evaluation. I
> > simply
> > copy/pasted ob-scala.el and made appropriate changes.
> >
> > I'm attaching ob-groovy.el as a file.
> >
> > All 3 tests pass, although I haven't created `testing/test-ob-groovy.el`
> -
> > I'll
> > look into that.
> >
> > --- testing last result 
> > #+BEGIN_SRC groovy
> > println "ignored"
> > 1 + 2
> > #+END_SRC
> >
> > #+RESULTS:
> > : 3
> > 
> >
> > --- testing results output --
> > #+BEGIN_SRC groovy :results output
> > println '1'
> > println '2'
> > println 1 + 2
> > #+END_SRC
> >
> > #+RESULTS:
> > =1
> > 2
> > 3
> > 
> >
> > --- testing table --
> > #+BEGIN_SRC groovy :results verbatim raw
> > """
> > | 1 | 2
> > |--
> > | a | b
> > """.trim()
> > #+END_SRC
> >
> > #+RESULTS:
> > | 1 | 2 |
> > |---+---|
> > | a | b |
> > 
> >
> >
> > Kind Regards,
> > Miro Bezjak
> > Hi all,
> >
> > I would like to contribute org-babel functions for Groovy evaluation.
> > I simply
> > copy/pasted ob-scala.el and made appropriate changes.
> >
> > I'm attaching ob-groovy.el as a file.
> >
> > All 3 tests pass, although I haven't created
> > `testing/test-ob-groovy.el` - I'll
> > look into that.
> >
> > --- testing last result 
> > #+BEGIN_SRC groovy
> > println "ignored"
> > 1 + 2
> > #+END_SRC
> >
> > #+RESULTS:
> > : 3
> > 
> >
> > --- testing results output --
> > #+BEGIN_SRC groovy :results output
> > println '1'
> > println '2'
> > println 1 + 2
> > #+END_SRC
> >
> > #+RESULTS:
> > =1
> > 2
> > 3
> > 
> >
> > --- testing table --
> > #+BEGIN_SRC groovy :results verbatim raw
> > """
> > | 1 | 2
> > |--
> > | a | b
> > """.trim()
> > #+END_SRC
> >
> > #+RESULTS:
> > | 1 | 2 |
> > |---+---|
> > | a | b |
> > 
> >
> > Kind Regards,
> > Miro Bezjak
> >
> >
>
> --
> Thomas S. Dye
> http://www.tsdye.com
>


Re: [O] Contribution: ob-groovy.el

2013-12-26 Thread Thomas S. Dye
Aloha Miro,

Thanks for your contribution to Org mode.

Have you signed the FSF papers so that ob-groovy.el can be added to Org
mode?  See:
http://orgmode.org/worg/org-contribute.html#sec-6

Contributions by authors who have not signed the FSF papers are
typically added to the contrib directory and are not distributed with
Emacs.

Also, are you willing to draft documentation?  For a link to a
documentation template, see:
http://orgmode.org/worg/org-contrib/babel/languages.html

I was going to suggest that you use the Scala documentation as a guide,
but it doesn't exist! In fact, Scala doesn't appear in Worg's list of
languages supported by Babel.  One of those days ...

Thanks again for your contribution.

All the best,
Tom

Miro Bezjak  writes:

> Hi all,
>
> I would like to contribute org-babel functions for Groovy evaluation. I
> simply
> copy/pasted ob-scala.el and made appropriate changes.
>
> I'm attaching ob-groovy.el as a file.
>
> All 3 tests pass, although I haven't created `testing/test-ob-groovy.el` -
> I'll
> look into that.
>
> --- testing last result 
> #+BEGIN_SRC groovy
> println "ignored"
> 1 + 2
> #+END_SRC
>
> #+RESULTS:
> : 3
> 
>
> --- testing results output --
> #+BEGIN_SRC groovy :results output
> println '1'
> println '2'
> println 1 + 2
> #+END_SRC
>
> #+RESULTS:
> =1
> 2
> 3
> 
>
> --- testing table --
> #+BEGIN_SRC groovy :results verbatim raw
> """
> | 1 | 2
> |--
> | a | b
> """.trim()
> #+END_SRC
>
> #+RESULTS:
> | 1 | 2 |
> |---+---|
> | a | b |
> 
>
>
> Kind Regards,
> Miro Bezjak
> Hi all,
>
> I would like to contribute org-babel functions for Groovy evaluation.
> I simply
> copy/pasted ob-scala.el and made appropriate changes.
>
> I'm attaching ob-groovy.el as a file.
>
> All 3 tests pass, although I haven't created
> `testing/test-ob-groovy.el` - I'll
> look into that.
>
> --- testing last result 
> #+BEGIN_SRC groovy
> println "ignored"
> 1 + 2
> #+END_SRC
>
> #+RESULTS:
> : 3
> 
>
> --- testing results output --
> #+BEGIN_SRC groovy :results output
> println '1'
> println '2'
> println 1 + 2
> #+END_SRC
>
> #+RESULTS:
> =1
> 2
> 3
> 
>
> --- testing table --
> #+BEGIN_SRC groovy :results verbatim raw
> """
> | 1 | 2
> |--
> | a | b
> """.trim()
> #+END_SRC
>
> #+RESULTS:
> | 1 | 2 |
> |---+---|
> | a | b |
> 
>
> Kind Regards,
> Miro Bezjak
>
>

-- 
Thomas S. Dye
http://www.tsdye.com



[O] Contribution: ob-groovy.el

2013-12-26 Thread Miro Bezjak
Hi all,

I would like to contribute org-babel functions for Groovy evaluation. I
simply
copy/pasted ob-scala.el and made appropriate changes.

I'm attaching ob-groovy.el as a file.

All 3 tests pass, although I haven't created `testing/test-ob-groovy.el` -
I'll
look into that.

--- testing last result 
#+BEGIN_SRC groovy
println "ignored"
1 + 2
#+END_SRC

#+RESULTS:
: 3


--- testing results output --
#+BEGIN_SRC groovy :results output
println '1'
println '2'
println 1 + 2
#+END_SRC

#+RESULTS:
=1
2
3


--- testing table --
#+BEGIN_SRC groovy :results verbatim raw
"""
| 1 | 2
|--
| a | b
""".trim()
#+END_SRC

#+RESULTS:
| 1 | 2 |
|---+---|
| a | b |



Kind Regards,
Miro Bezjak
;;; ob-groovy.el --- org-babel functions for Groovy evaluation

;; Copyright (C) 2013 Free Software Foundation, Inc.

;; Author: Miro Bezjak
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see .

;;; Commentary:
;; Currently only supports the external execution.  No session support yet.

;;; Requirements:
;; - Groovy language :: http://groovy.codehaus.org
;; - Groovy major mode :: Can be installed from MELPA or
;;   https://github.com/russel/Emacs-Groovy-Mode

;;; Code:
(require 'ob)
(eval-when-compile (require 'cl))

(defvar org-babel-tangle-lang-exts) ;; Autoloaded
(add-to-list 'org-babel-tangle-lang-exts '("groovy" . "groovy"))
(defvar org-babel-default-header-args:groovy '())
(defvar org-babel-groovy-command "groovy"
  "Name of the command to use for executing Groovy code.")

(defun org-babel-execute:groovy (body params)
  "Execute a block of Groovy code with org-babel.  This function is
called by `org-babel-execute-src-block'"
  (message "executing Groovy source code block")
  (let* ((processed-params (org-babel-process-params params))
 (session (org-babel-groovy-initiate-session (nth 0 processed-params)))
 (vars (nth 1 processed-params))
 (result-params (nth 2 processed-params))
 (result-type (cdr (assoc :result-type params)))
 (full-body (org-babel-expand-body:generic
 body params))
 (result (org-babel-groovy-evaluate
  session full-body result-type result-params)))

(org-babel-reassemble-table
 result
 (org-babel-pick-name
  (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
 (org-babel-pick-name
  (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))


(defun org-babel-groovy-table-or-string (results)
  "Convert RESULTS into an appropriate elisp value.
If RESULTS look like a table, then convert them into an
Emacs-lisp table, otherwise return the results as a string."
  (org-babel-script-escape results))


(defvar org-babel-groovy-wrapper-method

  "class Runner extends Script {
def out = new PrintWriter(new ByteArrayOutputStream())
def run() { %s }
}

println(new Runner().run())
")


(defun org-babel-groovy-evaluate
  (session body &optional result-type result-params)
  "Evaluate BODY in external Groovy process.
If RESULT-TYPE equals 'output then return standard output as a string.
If RESULT-TYPE equals 'value then return the value of the last statement
in BODY as elisp."
  (when session (error "Sessions are not (yet) supported for Groovy"))
  (case result-type
(output
 (let ((src-file (org-babel-temp-file "groovy-")))
   (progn (with-temp-file src-file (insert body))
  (org-babel-eval
   (concat org-babel-groovy-command " " src-file) ""
(value
 (let* ((src-file (org-babel-temp-file "groovy-"))
(wrapper (format org-babel-groovy-wrapper-method body)))
   (with-temp-file src-file (insert wrapper))
   (let ((raw (org-babel-eval
   (concat org-babel-groovy-command " " src-file) "")))
 (org-babel-result-cond result-params
	   raw
   (org-babel-groovy-table-or-string raw)))


(defun org-babel-prep-session:groovy (session params)
  "Prepare SESSION according to the header arguments specified in PARAMS."
  (error "Sessions are not (yet) supported for Groovy"))

(defun org-babel-groovy-initiate-session (&optional session)
  "If