From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] Handle literal 'hline arguments passed to ruby. Date: Mon, 2 Sep 2013 16:12:27 +0200 Message-ID: <66F0DF00-C2C2-499F-B219-5005A0116162@gmail.com> References: <2259d6df9973f724a883386e8bacee23@mail.rickster.com> Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGUrs-0006G5-W8 for emacs-orgmode@gnu.org; Mon, 02 Sep 2013 10:12:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGUrn-00017M-40 for emacs-orgmode@gnu.org; Mon, 02 Sep 2013 10:12:36 -0400 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]:33799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGUrm-00017H-TM for emacs-orgmode@gnu.org; Mon, 02 Sep 2013 10:12:31 -0400 Received: by mail-wg0-f43.google.com with SMTP id z12so1023989wgg.34 for ; Mon, 02 Sep 2013 07:12:30 -0700 (PDT) In-Reply-To: <2259d6df9973f724a883386e8bacee23@mail.rickster.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org 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 wrote: > Solution shamelessly copied from ob-python. >=20 > * 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(-) >=20 > 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.") >=20 > +(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)))) >=20 > (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))) >=20 > (defun org-babel-ruby-initiate-session (&optional session params) > "Initiate a ruby session. > --=20 > 1.8.0 >=20 >=20