From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Matthew MacLean <archenoth@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: ob-ruby org-babel-ruby-table-or-string numeric argument patch
Date: Sun, 16 Aug 2015 19:20:36 +0200 [thread overview]
Message-ID: <87bne7no9n.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CA+GZiYrfKFdOTPz3CukwDRKiD9XqBwu2jFjs=P+4QOrPPNkn8g@mail.gmail.com> (Matthew MacLean's message of "Mon, 10 Aug 2015 12:00:31 -0600")
Hello,
Matthew MacLean <archenoth@gmail.com> 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
next prev parent reply other threads:[~2015-08-16 17:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 18:00 ob-ruby org-babel-ruby-table-or-string numeric argument patch Matthew MacLean
2015-08-16 17:20 ` Nicolas Goaziou [this message]
2015-08-16 19:28 ` Kyle Meyer
2015-08-16 19:44 ` Matthew MacLean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bne7no9n.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=archenoth@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).