Browse Source

bringing back default values from properties

  originally in commit 6b5747fdfa7448bca87d23c9183e95f9208631f4
Eric Schulte 16 years ago
parent
commit
883a174357
2 changed files with 28 additions and 3 deletions
  1. 18 3
      lisp/org-babel.el
  2. 10 0
      test-tangle.org

+ 18 - 3
lisp/org-babel.el

@@ -159,7 +159,7 @@ Optionally supply a value for INFO in the form returned by
 Optionally supply a value for PARAMS which will be merged with
 Optionally supply a value for PARAMS which will be merged with
 the header arguments specified at the source code block."
 the header arguments specified at the source code block."
   (interactive)
   (interactive)
-  (message "supplied params=%S" params)
+  ;; (message "supplied params=%S" params) ;; debugging
   (let* ((info (or info (org-babel-get-src-block-info)))
   (let* ((info (or info (org-babel-get-src-block-info)))
          (lang (first info))
          (lang (first info))
          (body (second info))
          (body (second info))
@@ -170,7 +170,7 @@ the header arguments specified at the source code block."
 	 (result-type (fourth processed-params))
 	 (result-type (fourth processed-params))
          (cmd (intern (concat "org-babel-execute:" lang)))
          (cmd (intern (concat "org-babel-execute:" lang)))
          result)
          result)
-    (message "params=%S" params) ;; debugging statement
+    ;; (message "params=%S" params) ;; debugging statement
     (unless (member lang org-babel-interpreters)
     (unless (member lang org-babel-interpreters)
       (error "Language is not in `org-babel-interpreters': %s" lang))
       (error "Language is not in `org-babel-interpreters': %s" lang))
     (when arg (setq result-params (cons "silent" result-params)))
     (when arg (setq result-params (cons "silent" result-params)))
@@ -247,7 +247,7 @@ concerned with creating elisp versions of results. "
 
 
   (if (and (member "vector" result-params) (not (listp result)))
   (if (and (member "vector" result-params) (not (listp result)))
       (list (list result))
       (list (list result))
-         result))
+    result))
 
 
 (defun org-babel-execute-buffer (&optional arg)
 (defun org-babel-execute-buffer (&optional arg)
   "Replace EVAL snippets in the entire buffer."
   "Replace EVAL snippets in the entire buffer."
@@ -314,6 +314,19 @@ of the following form.  (language body header-arguments-alist)"
        (save-match-data ,@body)
        (save-match-data ,@body)
        (goto-char (match-end 0)))))
        (goto-char (match-end 0)))))
 
 
+(defun org-babel-params-from-properties ()
+  "Return an association list of any source block params which
+may be specified in the properties of the current outline entry."
+  (let ((org-babel-header-args '("results" "exports" "tangle")))
+    (delq nil
+          (mapcar
+           (lambda (header-arg)
+             (let ((val (org-entry-get (point) header-arg)))
+               (when val
+                 ;; (message "param-from-property %s=%s" header-arg val) ;; debugging statement
+                 (cons (intern (concat ":" header-arg)) val))))
+           org-babel-header-args))))
+
 (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)))
          (lang-headers (intern (concat "org-babel-default-header-args:" lang))))
          (lang-headers (intern (concat "org-babel-default-header-args:" lang))))
@@ -321,6 +334,7 @@ of the following form.  (language body header-arguments-alist)"
 	  (org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 4)))
 	  (org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 4)))
 	  (org-babel-merge-params
 	  (org-babel-merge-params
 	   org-babel-default-header-args
 	   org-babel-default-header-args
+           (org-babel-params-from-properties)
 	   (if (boundp lang-headers) (eval lang-headers) nil)
 	   (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) "")))))))
 
 
@@ -331,6 +345,7 @@ of the following form.  (language body header-arguments-alist)"
           (org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 4)))
           (org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 4)))
           (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)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (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) "")))))))
 
 

+ 10 - 0
test-tangle.org

@@ -96,3 +96,13 @@ plus_two(holder)
 #+begin_src emacs-lisp :tangle no
 #+begin_src emacs-lisp :tangle no
   (setq test-tangle-i-should-not-exist "hopefully I'm not included")
   (setq test-tangle-i-should-not-exist "hopefully I'm not included")
 #+end_src
 #+end_src
+
+*** Emacs Lisp (not to be tangled)
+    :PROPERTIES:
+    :tangle:   no
+    :END:
+
+#+srcname: i-also-shouldnt-be-tangled
+#+begin_src emacs-lisp 
+  (setq test-tangle-me-either "i also shouldn't be tangled")
+#+end_src