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.
This commit is contained in:
parent
41387f4675
commit
82c0f9bf69
2 changed files with 21 additions and 1 deletions
15
lisp/ob.el
15
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)))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue