From b21da5f5d6cb0f3e888ff018a3b2507c8ef2a3b8 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 12 Dec 2011 17:19:31 -0700 Subject: [PATCH] fixed bug in parsing of arguments to code block references * lisp/ob-ref.el (org-babel-ref-split-args): Now uses `org-babel-balanced-split'. * testing/lisp/test-ob.el (test-ob/splitting-variable-lists-in-references): Test new working behavior. --- lisp/ob-ref.el | 15 +-------------- testing/lisp/test-ob.el | 7 +++++++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index fb3bff616..304e47832 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -244,20 +244,7 @@ to \"0:-1\"." (defun org-babel-ref-split-args (arg-string) "Split ARG-STRING into top-level arguments of balanced parenthesis." - (let ((index 0) (depth 0) (buffer "") holder return) - ;; crawl along string, splitting at any ","s which are on the top level - (while (< index (length arg-string)) - (setq holder (substring arg-string index (+ 1 index))) - (setq buffer (concat buffer holder)) - (setq index (+ 1 index)) - (cond - ((string= holder ",") - (when (= depth 0) - (setq return (cons (substring buffer 0 -1) return)) - (setq buffer ""))) - ((or (string= holder "(") (string= holder "[")) (setq depth (+ depth 1))) - ((or (string= holder ")") (string= holder "]")) (setq depth (- depth 1))))) - (mapcar #'org-babel-trim (reverse (cons buffer return))))) + (mapcar #'org-babel-trim (org-babel-balanced-split arg-string 44))) (defvar org-bracket-link-regexp) (defun org-babel-ref-at-ref-p () diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 70b7dc720..6c7ac6c13 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -576,6 +576,13 @@ on two lines #+end_src" (should (string= (org-babel-expand-noweb-references) "barbaz")))) +(ert-deftest test-ob/splitting-variable-lists-in-references () + (org-test-with-temp-text "" + (should (= 1 (length (org-babel-ref-split-args + "a=\"this, no work\"")))) + (should (= 2 (length (org-babel-ref-split-args + "a=\"this, no work\", b=1")))))) + (provide 'test-ob) ;;; test-ob ends here -- 2.11.4.GIT