summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2011-11-20 09:40:08 -0700
committerEric Schulte <schulte.eric@gmail.com>2011-11-20 09:40:08 -0700
commit82c0f9bf69966f9d5737baa98f068725c82af2c4 (patch)
tree4ccca4b11acd2290a77263bf5a9c18aeaac7bbeb
parent41387f46753050d4f8b40a367d8f470f767d8daa (diff)
downloadorg-mode-82c0f9bf69966f9d5737baa98f068725c82af2c4.tar.gz
Allow spaces around "=" in code block variable specifications
* lisp/ob.el (org-babel-join-splits-near-ch): Rejoins a list of a split string when a character appears on either side of the split. (org-babel-parse-multiple-vars): Rejoin splits around "=" signs.
-rw-r--r--lisp/ob.el15
-rw-r--r--testing/lisp/test-ob.el7
2 files changed, 21 insertions, 1 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index 26a3af7..33013b8 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1151,6 +1151,18 @@ instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
(string-to-list string))
(nreverse (cons (apply #'string (nreverse partial)) lst)))))
+(defun org-babel-join-splits-near-ch (ch list)
+ "Join splits where \"=\" is on either end of the split."
+ (flet ((last= (str) (= ch (aref str (1- (length str)))))
+ (first= (str) (= ch (aref str 0))))
+ (reverse
+ (org-reduce (lambda (acc el)
+ (let ((head (car acc)))
+ (if (and head (or (last= head) (first= el)))
+ (cons (concat head el) (cdr acc))
+ (cons el acc))))
+ list :initial-value nil))))
+
(defun org-babel-parse-header-arguments (arg-string)
"Parse a string of header arguments returning an alist."
(when (> (length arg-string) 0)
@@ -1179,7 +1191,8 @@ shown below.
(mapc (lambda (pair)
(if (eq (car pair) :var)
(mapcar (lambda (v) (push (cons :var (org-babel-trim v)) results))
- (org-babel-balanced-split (cdr pair) 32))
+ (org-babel-join-splits-near-ch
+ 61 (org-babel-balanced-split (cdr pair) 32)))
(push pair results)))
header-arguments)
(nreverse results)))
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index d145f4e..47d3b16 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -497,6 +497,13 @@ on two lines
(org-babel-next-src-block 3)
(should (equal (org-babel-execute-src-block) "foo"))))
+(ert-deftest test-ob/allow-spaces-around-=-in-var-specs ()
+ (org-test-with-temp-text "#+begin_src emacs-lisp :var a = 1 b = 2 c= 3 d =4
+ (+ a b c d)
+#+end_src
+"
+ (should (= 10 (org-babel-execute-src-block)))))
+
(provide 'test-ob)
;;; test-ob ends here