Pārlūkot izejas kodu

Merge branch 'maint'

Nicolas Goaziou 7 gadi atpakaļ
vecāks
revīzija
5d4691dfbf
2 mainītis faili ar 34 papildinājumiem un 12 dzēšanām
  1. 9 12
      lisp/ob-ref.el
  2. 25 0
      testing/lisp/test-ob-lob.el

+ 9 - 12
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

+ 25 - 0
testing/lisp/test-ob-lob.el

@@ -168,6 +168,31 @@ for export
       (should
        (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\"
+'foo
+#+end_src
+
+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\"
+'bar
+#+end_src
+
+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