org-babel: parse src block switches

The switches are flags like -n and must *precede* the first colon
after the language (i.e. precede the first header argument). So the
general src block syntax is
\#+begin_src lang <switches> :header1 val1 :header2 val2 ...
...

org-babel-get-src-block-info now returns a list
(lang body params-alist switches)
This commit is contained in:
Dan Davison 2009-10-31 21:19:38 -04:00
parent c7d3844bd9
commit dcc669f20a
1 changed files with 7 additions and 3 deletions

View File

@ -112,7 +112,8 @@ then run `org-babel-pop-to-session'."
(concat "^[ \t]*#\\+begin_src[ \t]+\\(" ;; (1) lang
(mapconcat 'regexp-quote value "\\|")
"\\)[ \t]*"
"\\([ \t]+\\([^\n]+\\)\\)?\n" ;; (2, 3) (unused, headers)
"\\([^:\n]*\\)" ;; (2) switches
"\\([^\n]*\\)\n" ;; (3) header arguments
"\\([^\000]+?\\)#\\+end_src")) ;; (4) body
(setq org-babel-inline-src-block-regexp
(concat "[ \f\t\n\r\v]\\(src_" ;; (1) replacement target
@ -373,8 +374,10 @@ may be specified in the properties of the current outline entry."
(defun org-babel-parse-src-block-match ()
(let* ((lang (org-babel-clean-text-properties (match-string 1)))
(lang-headers (intern (concat "org-babel-default-header-args:" lang)))
(switches (match-string 2))
(body (org-babel-clean-text-properties (match-string 4)))
(preserve-indentation org-src-preserve-indentation))
(preserve-indentation (or org-src-preserve-indentation
(string-match "-i\\>" switches))))
(list lang
;; get src block body removing properties, protective commas, and indentation
(with-temp-buffer
@ -386,7 +389,8 @@ may be specified in the properties of the current outline entry."
org-babel-default-header-args
(org-babel-params-from-properties)
(if (boundp lang-headers) (eval lang-headers) nil)
(org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 3) "")))))))
(org-babel-parse-header-arguments (org-babel-clean-text-properties (or (match-string 3) ""))))
switches)))
(defun org-babel-parse-inline-src-block-match ()
(let* ((lang (org-babel-clean-text-properties (match-string 2)))