From 659663d7f053f85872e572aca83541b470070abf Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Thu, 9 May 2013 20:01:45 +0200 Subject: [PATCH 2/2] ob-core: allow language specific header arguments in properties * lisp/ob-core.el (org-babel-insert-header-arg, org-babel-parse-src-block-match): Replace `if' with empty else part by `when' for readability. (org-babel-parse-src-block-match, org-babel-parse-inline-src-block-match): Inquire for language specific header args from properties and integrate them after other default header args. This allows for header arguments to be specified as properties (including inheritance). #+PROPERTY: header-args:R :session "*R-property*" :PROPERTIES: :header-args:R: :session "*R-drawer*" :END: --- lisp/ob-core.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 06d2520..c719089 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -757,7 +757,7 @@ (defun org-babel-insert-header-arg () (lang-headers (intern (concat "org-babel-header-args:" lang))) (headers (org-babel-combine-header-arg-lists org-babel-common-header-args-w-values - (if (boundp lang-headers) (eval lang-headers) nil))) + (when (boundp lang-headers) (eval lang-headers)))) (arg (org-icompleting-read "Header Arg: " (mapcar @@ -1309,6 +1309,9 @@ (defun org-babel-parse-src-block-match () (let* ((block-indentation (length (match-string 1))) (lang (org-no-properties (match-string 2))) (lang-headers (intern (concat "org-babel-default-header-args:" lang))) + (lang-props (save-match-data + (org-entry-get (point) (concat "header-args:" lang) + 'inherit 'literal-nil))) (switches (match-string 3)) (body (org-no-properties (let* ((body (match-string 5)) @@ -1329,8 +1332,9 @@ (defun org-babel-parse-src-block-match () (buffer-string))) (org-babel-merge-params org-babel-default-header-args - (if (boundp lang-headers) (eval lang-headers) nil) + (when (boundp lang-headers) (eval lang-headers)) (org-babel-params-from-properties lang) + (org-babel-parse-header-arguments lang-props) (org-babel-parse-header-arguments (org-no-properties (or (match-string 4) "")))) switches @@ -1339,6 +1343,9 @@ (defun org-babel-parse-src-block-match () (defun org-babel-parse-inline-src-block-match () "Parse the results from a match of the `org-babel-inline-src-block-regexp'." (let* ((lang (org-no-properties (match-string 2))) + (lang-props (save-match-data + (org-entry-get (point) (concat "header-args:" lang) + 'inherit 'literal-nil))) (lang-headers (intern (concat "org-babel-default-header-args:" lang)))) (list lang (org-unescape-code-in-string (org-no-properties (match-string 5))) -- 1.8.2.1