* [BUG] hline handling in ob-ruby
@ 2013-08-27 14:42 Rick Frankel
2013-08-31 16:48 ` Eric Schulte
0 siblings, 1 reply; 2+ messages in thread
From: Rick Frankel @ 2013-08-27 14:42 UTC (permalink / raw)
To: eric.schulte; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
Eric-
There is a bug in ob-ruby --- if an literal 'hline is passed into
(e.g., :hline no) a ruby block, the execution fails due to an
incorrect datatype (this is not an issue in any other language). The
patch provided in
http://lists.gnu.org/archive/html/emacs-orgmode/2013-08/msg00316.html
(and reattached here), applies the solution used in ox-python to
handle the issue. An alternative solution is ok too :).
I would be glad to apply the patch myself, but since you are the owner
of the file i would appreciate you ok before proceeding.
tia,
rick
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Handle-literal-hline-arguments-passed-to-ruby.patch --]
[-- Type: text/x-lisp; name=0001-Handle-literal-hline-arguments-passed-to-ruby.patch, Size: 2238 bytes --]
From 4ae86a04680bcf671d43bb0b70bfddd083b743b2 Mon Sep 17 00:00:00 2001
From: Rick Frankel <rick@rickster.com>
Date: Thu, 15 Aug 2013 14:43:51 -0400
Subject: [PATCH] Handle literal 'hline arguments passed to ruby. 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] 2+ messages in thread
* Re: [BUG] hline handling in ob-ruby
2013-08-27 14:42 [BUG] hline handling in ob-ruby Rick Frankel
@ 2013-08-31 16:48 ` Eric Schulte
0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2013-08-31 16:48 UTC (permalink / raw)
To: Rick Frankel; +Cc: emacs-orgmode, eric.schulte
Sorry about the delay in replying, apparently gmail has decided to
redirect large chunks of the Org-mode mailing list into my spam folder.
Perhaps it would be better to not use my @gmx account in the future.
Please do go ahead and apply this patch. Thanks for porting this
solution over from ob-python, and sorry again about the delay!
Rick Frankel <rick@rickster.com> writes:
> Eric-
>
> There is a bug in ob-ruby --- if an literal 'hline is passed into
> (e.g., :hline no) a ruby block, the execution fails due to an
> incorrect datatype (this is not an issue in any other language). The
> patch provided in
> http://lists.gnu.org/archive/html/emacs-orgmode/2013-08/msg00316.html
> (and reattached here), applies the solution used in ox-python to
> handle the issue. An alternative solution is ok too :).
>
> I would be glad to apply the patch myself, but since you are the owner
> of the file i would appreciate you ok before proceeding.
>
> tia,
> rick
>
> From 4ae86a04680bcf671d43bb0b70bfddd083b743b2 Mon Sep 17 00:00:00 2001
> From: Rick Frankel <rick@rickster.com>
> Date: Thu, 15 Aug 2013 14:43:51 -0400
> Subject: [PATCH] Handle literal 'hline arguments passed to ruby. 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.
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-31 16:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-27 14:42 [BUG] hline handling in ob-ruby Rick Frankel
2013-08-31 16:48 ` Eric Schulte
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.