emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Handle literal 'hline arguments passed to ruby.
@ 2013-08-15 18:50 Rick Frankel
  2013-09-02  5:30 ` Carsten Dominik
  2013-09-02 14:12 ` Carsten Dominik
  0 siblings, 2 replies; 7+ messages in thread
From: Rick Frankel @ 2013-08-15 18:50 UTC (permalink / raw)
  To: emacs-orgmode

Solution shamelessly copied from ob-python.

* lisp/ob-ruby.el: New customizations `org-babel-ruby-hline-to' and
`org-babel-ruby-nil-to'
(org-babel-ruby-var-to-ruby): Convert incoming 'hlines.
(org-babel-ruby-table-or-string): Convert outgoing nils.
---
lisp/ob-ruby.el | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
index 20fb418..d15d288 100644
--- a/lisp/ob-ruby.el
+++ b/lisp/ob-ruby.el
@@ -50,6 +50,20 @@
(defvar org-babel-ruby-command "ruby"
"Name of command to use for executing ruby code.")

+(defcustom org-babel-ruby-hline-to "nil"
+  "Replace hlines in incoming tables with this when translating to 
ruby."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-babel-ruby-nil-to 'hline
+  "Replace 'nil' in ruby tables with this before returning."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
(defun org-babel-execute:ruby (body params)
"Execute a block of Ruby code with Babel.
This function is called by `org-babel-execute-src-block'."
@@ -115,13 +129,21 @@ Convert an elisp value into a string of ruby 
source code
specifying a variable of the same value."
(if (listp var)
(concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", ") "]")
-    (format "%S" var)))
+    (if (equal var 'hline)
+	org-babel-ruby-hline-to
+      (format "%S" var))))

(defun org-babel-ruby-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))
+  ((lambda (res)
+     (if (listp res)
+	 (mapcar (lambda (el) (if (equal el 'nil)
+				  org-babel-ruby-nil-to el))
+		 res)
+       res))
+   (org-babel-script-escape results)))

(defun org-babel-ruby-initiate-session (&optional session params)
"Initiate a ruby session.
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle literal 'hline arguments passed to ruby.
  2013-08-15 18:50 [PATCH] Handle literal 'hline arguments passed to ruby Rick Frankel
@ 2013-09-02  5:30 ` Carsten Dominik
  2013-09-02 10:54   ` Bastien
  2013-09-02 14:12 ` Carsten Dominik
  1 sibling, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2013-09-02  5:30 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode

Hi Rick,

are you a signed contributor?

- Carsten

On 15.8.2013, at 20:50, Rick Frankel <rick@rickster.com> wrote:

> Solution shamelessly copied from ob-python.
> 
> * lisp/ob-ruby.el: New customizations `org-babel-ruby-hline-to' and
> `org-babel-ruby-nil-to'
> (org-babel-ruby-var-to-ruby): Convert incoming 'hlines.
> (org-babel-ruby-table-or-string): Convert outgoing nils.
> ---
> lisp/ob-ruby.el | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
> index 20fb418..d15d288 100644
> --- a/lisp/ob-ruby.el
> +++ b/lisp/ob-ruby.el
> @@ -50,6 +50,20 @@
> (defvar org-babel-ruby-command "ruby"
> "Name of command to use for executing ruby code.")
> 
> +(defcustom org-babel-ruby-hline-to "nil"
> +  "Replace hlines in incoming tables with this when translating to ruby."
> +  :group 'org-babel
> +  :version "24.4"
> +  :package-version '(Org . "8.0")
> +  :type 'string)
> +
> +(defcustom org-babel-ruby-nil-to 'hline
> +  "Replace 'nil' in ruby tables with this before returning."
> +  :group 'org-babel
> +  :version "24.4"
> +  :package-version '(Org . "8.0")
> +  :type 'string)
> +
> (defun org-babel-execute:ruby (body params)
> "Execute a block of Ruby code with Babel.
> This function is called by `org-babel-execute-src-block'."
> @@ -115,13 +129,21 @@ Convert an elisp value into a string of ruby source code
> specifying a variable of the same value."
> (if (listp var)
> (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", ") "]")
> -    (format "%S" var)))
> +    (if (equal var 'hline)
> +	org-babel-ruby-hline-to
> +      (format "%S" var))))
> 
> (defun org-babel-ruby-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))
> +  ((lambda (res)
> +     (if (listp res)
> +	 (mapcar (lambda (el) (if (equal el 'nil)
> +				  org-babel-ruby-nil-to el))
> +		 res)
> +       res))
> +   (org-babel-script-escape results)))
> 
> (defun org-babel-ruby-initiate-session (&optional session params)
> "Initiate a ruby session.
> -- 
> 1.8.0
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle literal 'hline arguments passed to ruby.
  2013-09-02  5:30 ` Carsten Dominik
@ 2013-09-02 10:54   ` Bastien
  2013-09-02 14:05     ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2013-09-02 10:54 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Rick Frankel, emacs-orgmode

Hi Carsten and Rick,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> are you a signed contributor?

yes, Rick is listed on http://orgmode.org/worg/org-contribute.html

I keep the list as up-to-date as possible.

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle literal 'hline arguments passed to ruby.
  2013-09-02 10:54   ` Bastien
@ 2013-09-02 14:05     ` Carsten Dominik
  0 siblings, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2013-09-02 14:05 UTC (permalink / raw)
  To: Bastien; +Cc: Rick Frankel, emacs-orgmode


On Sep 2, 2013, at 12:54 PM, Bastien <bzg@gnu.org> wrote:

> Hi Carsten and Rick,
> 
> Carsten Dominik <carsten.dominik@gmail.com> writes:
> 
>> are you a signed contributor?
> 
> yes, Rick is listed on http://orgmode.org/worg/org-contribute.html
> 
> I keep the list as up-to-date as possible.

And I do look there, but looked in the wrong place.  Thanks.

- Carsten

> 
> Best,
> 
> -- 
> Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle literal 'hline arguments passed to ruby.
  2013-08-15 18:50 [PATCH] Handle literal 'hline arguments passed to ruby Rick Frankel
  2013-09-02  5:30 ` Carsten Dominik
@ 2013-09-02 14:12 ` Carsten Dominik
  2013-09-04 13:12   ` Rick Frankel
  1 sibling, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2013-09-02 14:12 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode

Applied, thank.

Rick, I had trouble applying th patch, so did some handywork - please check after me.

Thank you!

- Carsten

On Aug 15, 2013, at 8:50 PM, Rick Frankel <rick@rickster.com> wrote:

> Solution shamelessly copied from ob-python.
> 
> * lisp/ob-ruby.el: New customizations `org-babel-ruby-hline-to' and
> `org-babel-ruby-nil-to'
> (org-babel-ruby-var-to-ruby): Convert incoming 'hlines.
> (org-babel-ruby-table-or-string): Convert outgoing nils.
> ---
> lisp/ob-ruby.el | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
> index 20fb418..d15d288 100644
> --- a/lisp/ob-ruby.el
> +++ b/lisp/ob-ruby.el
> @@ -50,6 +50,20 @@
> (defvar org-babel-ruby-command "ruby"
> "Name of command to use for executing ruby code.")
> 
> +(defcustom org-babel-ruby-hline-to "nil"
> +  "Replace hlines in incoming tables with this when translating to ruby."
> +  :group 'org-babel
> +  :version "24.4"
> +  :package-version '(Org . "8.0")
> +  :type 'string)
> +
> +(defcustom org-babel-ruby-nil-to 'hline
> +  "Replace 'nil' in ruby tables with this before returning."
> +  :group 'org-babel
> +  :version "24.4"
> +  :package-version '(Org . "8.0")
> +  :type 'string)
> +
> (defun org-babel-execute:ruby (body params)
> "Execute a block of Ruby code with Babel.
> This function is called by `org-babel-execute-src-block'."
> @@ -115,13 +129,21 @@ Convert an elisp value into a string of ruby source code
> specifying a variable of the same value."
> (if (listp var)
> (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", ") "]")
> -    (format "%S" var)))
> +    (if (equal var 'hline)
> +	org-babel-ruby-hline-to
> +      (format "%S" var))))
> 
> (defun org-babel-ruby-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))
> +  ((lambda (res)
> +     (if (listp res)
> +	 (mapcar (lambda (el) (if (equal el 'nil)
> +				  org-babel-ruby-nil-to el))
> +		 res)
> +       res))
> +   (org-babel-script-escape results)))
> 
> (defun org-babel-ruby-initiate-session (&optional session params)
> "Initiate a ruby session.
> -- 
> 1.8.0
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle literal 'hline arguments passed to ruby.
  2013-09-02 14:12 ` Carsten Dominik
@ 2013-09-04 13:12   ` Rick Frankel
  2013-09-04 13:48     ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Rick Frankel @ 2013-09-04 13:12 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

On 2013-09-02 10:12, Carsten Dominik wrote:
> Applied, thank.
> 
> Rick, I had trouble applying th patch, so did some handywork - please
> check after me.

looks good modulo a couple of extra blank lines :).

thanx,
rick

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Handle literal 'hline arguments passed to ruby.
  2013-09-04 13:12   ` Rick Frankel
@ 2013-09-04 13:48     ` Carsten Dominik
  0 siblings, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2013-09-04 13:48 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode


On Sep 4, 2013, at 3:12 PM, Rick Frankel <rick@rickster.com> wrote:

> On 2013-09-02 10:12, Carsten Dominik wrote:
>> Applied, thank.
>> Rick, I had trouble applying th patch, so did some handywork - please
>> check after me.
> 
> looks good modulo a couple of extra blank lines :).


Thank you for checking.

- Carsten
> 
> thanx,
> rick

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-09-04 13:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-15 18:50 [PATCH] Handle literal 'hline arguments passed to ruby Rick Frankel
2013-09-02  5:30 ` Carsten Dominik
2013-09-02 10:54   ` Bastien
2013-09-02 14:05     ` Carsten Dominik
2013-09-02 14:12 ` Carsten Dominik
2013-09-04 13:12   ` Rick Frankel
2013-09-04 13:48     ` Carsten Dominik

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).