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.
This commit is contained in:
Eric Schulte 2011-12-12 17:19:31 -07:00
parent 4ecf626ee7
commit b21da5f5d6
2 changed files with 8 additions and 14 deletions

View File

@ -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 ()

View File

@ -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