summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-11-23 09:39:26 -0700
committerEric Schulte <schulte.eric@gmail.com>2010-11-23 09:39:26 -0700
commitd24b04d82f7e2a566f55c85bfe100db0ee59ff12 (patch)
treef707ea1e00318a7be059e63c0095be4cd52f53d1
parent90bd46a6d5ba55e4848a09d7d4c6e04e8aa9d62e (diff)
downloadorg-mode-d24b04d82f7e2a566f55c85bfe100db0ee59ff12.tar.gz
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).
-rw-r--r--lisp/ob.el2
-rw-r--r--testing/examples/babel.org11
-rw-r--r--testing/lisp/test-ob-lob.el7
-rw-r--r--testing/lisp/test-ob.el15
4 files changed, 28 insertions, 7 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index 2cb074d..a8a269e 100644
--- a/lisp/ob.el
+++ b/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
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index c934152..6ca7c2f 100644
--- a/testing/examples/babel.org
+++ b/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
diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el
index 5d3dddd..92ba967 100644
--- a/testing/lisp/test-ob-lob.el
+++ b/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)
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index f937c99..fde9887 100644
--- a/testing/lisp/test-ob.el
+++ b/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 \ No newline at end of file
+;;; test-ob ends here