Browse Source

ob: cleaner parsing of header arguments

  Thanks to Charles C. Berry for insisting on this issues existence

  This change is now secured with a unit test

* lisp/ob.el (org-babel-parse-header-arguments): Stripping trailing
  spaces off of header arguments (even the first one).
Eric Schulte 14 years ago
parent
commit
d24b04d82f
4 changed files with 28 additions and 7 deletions
  1. 1 1
      lisp/ob.el
  2. 10 1
      testing/examples/babel.org
  3. 3 4
      testing/lisp/test-ob-lob.el
  4. 14 1
      testing/lisp/test-ob.el

+ 1 - 1
lisp/ob.el

@@ -911,7 +911,7 @@ may be specified at the top of the current buffer."
 		  arg)
 		 (cons (intern (match-string 1 arg))
 		       (org-babel-read (org-babel-chomp (match-string 2 arg))))
-	       (cons (intern arg) nil)))
+	       (cons (intern (org-babel-chomp arg)) nil)))
 	   (let ((balance 0) (partial nil) (lst nil) (last 0))
 	     (mapc (lambda (ch)  ; split on [] balanced instances of [ \t]:
 		     (setq balance (+ balance

+ 10 - 1
testing/examples/babel.org

@@ -143,10 +143,19 @@
 * executing an lob call line
   :PROPERTIES:
   :results:  silent
+  :ID:       fab7e291-fde6-45fc-bf6e-a485b8bca2f0
   :END:
 
-69fbe856-ca9c-4f20-9146-826d2f488c1d
 #+call: echo(input="testing")
 #+call: echo(input="testing") :results vector
 #+call: echo[:var input="testing"]()
 #+call: echo[:var input="testing"]() :results vector
+
+* parsing header arguments
+  :PROPERTIES:
+  :ID:       7eb0dc6e-1c53-4275-88b3-b22f3113b9c3
+  :END:
+
+#+begin_src example-lang :session     :results output :var num=9
+  the body
+#+end_src

+ 3 - 4
testing/lisp/test-ob-lob.el

@@ -28,11 +28,10 @@
 
 (ert-deftest test-ob-lob/call-with-header-arguments ()
   "Test the evaluation of a library of babel #+call: line."
-  (org-test-at-marker
-      (expand-file-name "babel.org" org-test-example-dir)
-      "69fbe856-ca9c-4f20-9146-826d2f488c1d"
+  (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0"
     (move-beginning-of-line 1)
-    (forward-line 1)
+    (forward-line 6)
+    (message (buffer-substring (point-at-bol) (point-at-eol)))
     (should (string= "testing" (org-babel-lob-execute
 				(org-babel-lob-get-info))))
     (forward-line 1)

+ 14 - 1
testing/lisp/test-ob.el

@@ -70,6 +70,19 @@
     (should (string= "7374bf4f8a18dfcb6f365f93d15f1a0ef42db745"
 		     (org-babel-sha1-hash)))))
 
+(ert-deftest test-org-babel/parse-header-args ()
+  (org-test-at-id "7eb0dc6e-1c53-4275-88b3-b22f3113b9c3"
+    (org-babel-next-src-block)
+    (let* ((info (org-babel-get-src-block-info))
+	   (params (nth 2 info)))
+      (message "%S" params)
+      (should (equal "example-lang" (nth 0 info)))
+      (should (string= "the body" (org-babel-trim (nth 1 info))))
+      (should-not (member '(:session\ \ \ \ ) params))
+      (should (equal '(:session) (assoc :session params)))
+      (should (equal '(:result-type . output) (assoc :result-type params)))
+      (should (equal '(num . 9) (cdr (assoc :var params)))))))
+
 (provide 'test-ob)
 
-;;; test-ob ends here
+;;; test-ob ends here