diff options
authorNicolas Goaziou <>2017-12-14 23:00:55 (GMT)
committer Nicolas Goaziou <>2017-12-14 23:00:55 (GMT)
commit5d4691dfbfea29cf2ecf8df8a97378082a573564 (patch)
parent6fc4a1c53b5e04498b62fdd068cf4b020ad2d2c3 (diff)
parent327ca051ae4631fea57427290bb16bf9174a4311 (diff)
Merge branch 'maint'HEADmaster
2 files changed, 34 insertions, 12 deletions
diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el
index 323cdc7..b44aa1e 100644
--- a/lisp/ob-ref.el
+++ b/lisp/ob-ref.el
@@ -65,24 +65,21 @@
(declare-function org-show-context "org" (&optional key))
(declare-function org-trim "org" (s &optional keep-lead))
-(defvar org-babel-ref-split-regexp
- "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*")
(defvar org-babel-update-intermediate nil
"Update the in-buffer results of code blocks executed to resolve references.")
(defun org-babel-ref-parse (assignment)
"Parse a variable ASSIGNMENT in a header argument.
If the right hand side of the assignment has a literal value
-return that value, otherwise interpret as a reference to an
-external resource and find its value using
-`org-babel-ref-resolve'. Return a list with two elements. The
-first element of the list will be the name of the variable, and
-the second will be an emacs-lisp representation of the value of
-the variable."
- (when (string-match org-babel-ref-split-regexp assignment)
- (let ((var (match-string 1 assignment))
- (ref (match-string 2 assignment)))
+return that value, otherwise interpret it as a reference to an
+external resource and find its value using `org-babel-ref-resolve'.
+Return a list with two elements: the name of the variable, and an
+Emacs Lisp representation of the value of the variable."
+ (when (string-match "\\(.+?\\)=" assignment)
+ (let ((var (org-trim (match-string 1 assignment)))
+ (ref (org-trim (substring assignment (match-end 0)))))
(cons (intern var)
(let ((out (save-excursion
(when org-babel-current-src-block-location
diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el
index bb933b4..49f1f24 100644
--- a/testing/lisp/test-ob-lob.el
+++ b/testing/lisp/test-ob-lob.el
@@ -168,6 +168,31 @@ for export
(eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)))))
+(ert-deftest test-ob-lob/assignment-with-newline ()
+ "Test call lines with an argument containing a newline character."
+ (should
+ (equal " foo"
+ (org-test-with-temp-text "
+#+name: test-newline
+#+begin_src emacs-lisp :var x=\"a\"
+call_test-newline[:eval yes :results raw](\"a\nb\")<point>"
+ (org-babel-execute-src-block nil (org-babel-lob-get-info))
+ (buffer-substring (point) (point-max)))))
+ (should
+ (equal " bar"
+ (org-test-with-temp-text "
+#+name: test-newline
+#+begin_src emacs-lisp :var x=\"a\"
+call_test-newline[:eval yes :results raw]('(1\n2))<point>"
+ (org-babel-execute-src-block nil (org-babel-lob-get-info))
+ (buffer-substring (point) (point-max))))))
(provide 'test-ob-lob)
;;; test-ob-lob.el ends here