From 693dda67e60530c9f7b2510f44f6d14595473e28 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Fri, 7 Jun 2013 22:19:38 +0200 Subject: [PATCH] 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-params-from-properties): Inquire for language specific and default header properties. Language specific header properties take precedence over default header properties and old-style header property specifications. This allows for header arguments to be specified as properties (including inheritance). #+PROPERTY: header-args :cache "no" #+PROPERTY: header-args:R :session "*R-property*" :PROPERTIES: :header-args: :cache "yes" :header-args:R: :session "*R-drawer*" :END: --- lisp/ob-core.el | 50 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index a678ce8e1..d339475e7 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -766,7 +766,7 @@ arguments and pop open the results in a preview buffer." (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 @@ -1294,23 +1294,35 @@ portions of results lines." Return an association list of any source block params which may be specified in the properties of the current outline entry." (save-match-data - (let (val sym) - (org-babel-parse-multiple-vars - (delq nil - (mapcar - (lambda (header-arg) - (and (setq val (org-entry-get (point) header-arg t)) - (cons (intern (concat ":" header-arg)) - (org-babel-read val)))) - (mapcar - #'symbol-name - (mapcar - #'car - (org-babel-combine-header-arg-lists - org-babel-common-header-args-w-values - (progn - (setq sym (intern (concat "org-babel-header-args:" lang))) - (and (boundp sym) (eval sym)))))))))))) + (let* ((lang-props + (save-match-data + (org-babel-parse-header-arguments + (org-entry-get (point) (concat "header-args:" lang) + 'inherit)))) + (default-props + (save-match-data + (org-babel-parse-header-arguments + (org-entry-get (point) "header-args" + 'inherit)))) + (props + (let (val sym) + (org-babel-parse-multiple-vars + (delq nil + (mapcar + (lambda (header-arg) + (and (setq val (org-entry-get (point) header-arg t)) + (cons (intern (concat ":" header-arg)) + (org-babel-read val)))) + (mapcar + #'symbol-name + (mapcar + #'car + (org-babel-combine-header-arg-lists + org-babel-common-header-args-w-values + (progn + (setq sym (intern (concat "org-babel-header-args:" lang))) + (and (boundp sym) (eval sym)))))))))))) + (org-babel-merge-params props default-props lang-props)))) (defvar org-src-preserve-indentation) (defun org-babel-parse-src-block-match () @@ -1338,7 +1350,7 @@ may be specified in the properties of the current outline entry." (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 (org-no-properties (or (match-string 4) ""))))