Browse Source

babel: check properties for language-specific header arguments

* contrib/babel/lisp/org-babel.el
(org-babel-params-from-properties):
Check for language-specific header arguments
(org-babel-parse-src-block-match):
Pass lang parameter when checking properties for header args
(org-babel-parse-inline-src-block-match):
Pass lang parameter when checking properties for header args
Dan Davison 15 years ago
parent
commit
71cd358e21
1 changed files with 20 additions and 14 deletions
  1. 20 14
      contrib/babel/lisp/org-babel.el

+ 20 - 14
contrib/babel/lisp/org-babel.el

@@ -571,21 +571,27 @@ with C-c C-c."
          (goto-char (match-end 0))))
          (goto-char (match-end 0))))
      (unless visited-p (kill-buffer (file-name-nondirectory ,file)))))
      (unless visited-p (kill-buffer (file-name-nondirectory ,file)))))
 
 
-(defun org-babel-params-from-properties ()
+(defun org-babel-params-from-properties (&optional lang)
   "Return an association list of any source block params which
   "Return an association list of any source block params which
 may be specified in the properties of the current outline entry."
 may be specified in the properties of the current outline entry."
   (save-match-data
   (save-match-data
-    (delq nil
-          (mapcar
-           (lambda (header-arg)
-             (let ((val (or (condition-case nil
-                                (org-entry-get (point) header-arg t)
-                              (error nil))
-                            (cdr (assoc header-arg org-file-properties)))))
-               (when val
-                 ;; (message "prop %s=%s" header-arg val) ;; debugging
-                 (cons (intern (concat ":" header-arg)) val))))
-           (mapcar 'symbol-name org-babel-header-arg-names)))))
+    (let (val sym)
+      (delq nil
+	    (mapcar
+	     (lambda (header-arg)
+	       (and (setq val
+			  (or (condition-case nil
+				  (org-entry-get (point) header-arg t)
+				(error nil))
+			      (cdr (assoc header-arg org-file-properties))))
+		    (cons (intern (concat ":" header-arg)) val)))
+	     (mapcar
+	      'symbol-name
+	      (append
+	       org-babel-header-arg-names
+	       (progn
+		 (setq sym (intern (concat "org-babel-header-arg-names:" lang)))
+		 (and (boundp sym) (eval sym))))))))))
 
 
 (defun org-babel-parse-src-block-match ()
 (defun org-babel-parse-src-block-match ()
   (let* ((lang (org-babel-clean-text-properties (match-string 1)))
   (let* ((lang (org-babel-clean-text-properties (match-string 1)))
@@ -603,7 +609,7 @@ may be specified in the properties of the current outline entry."
               (buffer-string)))
               (buffer-string)))
 	  (org-babel-merge-params
 	  (org-babel-merge-params
 	   org-babel-default-header-args
 	   org-babel-default-header-args
-           (org-babel-params-from-properties)
+           (org-babel-params-from-properties lang)
 	   (if (boundp lang-headers) (eval lang-headers) nil)
 	   (if (boundp lang-headers) (eval lang-headers) nil)
 	   (org-babel-parse-header-arguments
 	   (org-babel-parse-header-arguments
             (org-babel-clean-text-properties (or (match-string 3) ""))))
             (org-babel-clean-text-properties (or (match-string 3) ""))))
@@ -617,7 +623,7 @@ may be specified in the properties of the current outline entry."
            (org-babel-clean-text-properties (match-string 5)))
            (org-babel-clean-text-properties (match-string 5)))
           (org-babel-merge-params
           (org-babel-merge-params
            org-babel-default-inline-header-args
            org-babel-default-inline-header-args
-           (org-babel-params-from-properties)
+           (org-babel-params-from-properties lang)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (org-babel-parse-header-arguments
            (org-babel-parse-header-arguments
             (org-babel-clean-text-properties (or (match-string 4) "")))))))
             (org-babel-clean-text-properties (or (match-string 4) "")))))))