From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: ob-ruby org-babel-ruby-table-or-string numeric argument patch Date: Sun, 16 Aug 2015 19:20:36 +0200 Message-ID: <87bne7no9n.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZR1aH-00013t-IP for emacs-orgmode@gnu.org; Sun, 16 Aug 2015 13:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZR1aG-0002bc-Cx for emacs-orgmode@gnu.org; Sun, 16 Aug 2015 13:19:01 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:44875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZR1aG-0002bT-5b for emacs-orgmode@gnu.org; Sun, 16 Aug 2015 13:19:00 -0400 In-Reply-To: (Matthew MacLean's message of "Mon, 10 Aug 2015 12:00:31 -0600") 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: Matthew MacLean Cc: emacs-orgmode@gnu.org Hello, Matthew MacLean writes: > Could you review my patch? Thanks..! Thank you for the patch. > diff --git a/lisp/ob-core.el b/lisp/ob-core.el > index e3abe97..01c4da8 100644 > --- a/lisp/ob-core.el > +++ b/lisp/ob-core.el > @@ -2813,34 +2813,37 @@ block but are passed literally to the \"example-block\"." > (error "Unterminated string in `org-babel-script-escape'")) > (apply #'string (reverse out)))) > > -(defun org-babel-script-escape (str &optional force) > - "Safely convert tables into elisp lists." > - (unless (stringp str) > - (error "`org-babel-script-escape' expects a string")) > - (let ((escaped > - (cond > - ((and (> (length str) 2) > - (or (and (string-equal "[" (substring str 0 1)) > - (string-equal "]" (substring str -1))) > - (and (string-equal "{" (substring str 0 1)) > - (string-equal "}" (substring str -1))) > - (and (string-equal "(" (substring str 0 1)) > - (string-equal ")" (substring str -1))))) > - > - (concat "'" (org-babel--script-escape-inner str))) > - ((or force > - (and (> (length str) 2) > - (or (and (string-equal "'" (substring str 0 1)) > - (string-equal "'" (substring str -1))) > - ;; We need to pass double-quoted strings > - ;; through the backslash-twiddling bits, even > - ;; though we don't need to change their > - ;; delimiters. > - (and (string-equal "\"" (substring str 0 1)) > - (string-equal "\"" (substring str -1)))))) > - (org-babel--script-escape-inner str)) > - (t str)))) > - (condition-case nil (org-babel-read escaped) (error escaped)))) > +(defun org-babel-script-escape (val &optional force) > + "Safely convert passed in values (including collections of > +them; tables) into elisp lists." First sentence in docstring has to fit in a single line. > + (if (numberp val) > + val > + (unless (stringp val) > + (error "`org-babel-script-escape' expects a string or number")) > + (let ((escaped Arguably, a `cond' might look nicer: (cond ((numberp val) val) ((not (stringp val) (error ...))) (t (let ((escaped ...)) ...))) Could you add a test for that in `test-org-babel/script-escape' (test-ob.el)? Regards, -- Nicolas Goaziou