summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-09-18 19:01:49 -0600
committerEric Schulte <schulte.eric@gmail.com>2010-09-18 19:57:36 -0600
commitefdf78172d9f7c0070c781d136a9b49a2a56fcc4 (patch)
tree9723d0ce8aaf107cff6d7e8e4631ddbd0398b65c
parentfbb828a1077d4d8879b00beab2923876d93416e7 (diff)
downloadorg-mode-efdf78172d9f7c0070c781d136a9b49a2a56fcc4.tar.gz
ob-exp: resolving code block parameters in the original file on export
* lisp/ob-exp.el (org-babel-exp-src-blocks): now switching back to the original file before resolving code block parameters to ensure headline and buffer wide parameters are taken into consideration when only a narrowed portion of the file is exported
-rw-r--r--lisp/ob-exp.el35
1 files changed, 31 insertions, 4 deletions
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index aec7d31..010c9ca 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -95,14 +95,41 @@ none ----- do not display either code or results upon export"
(message "org-babel-exp processing...")
(save-excursion
(goto-char (match-beginning 0))
- (let* ((info (org-babel-get-src-block-info))
- (params (nth 2 info)))
+ (let* ((raw-header (match-string 3))
+ (info (org-babel-get-src-block-info))
+ (lang (nth 0 info))
+ (lang-headers
+ (intern (concat "org-babel-default-header-args:" lang)))
+ (raw-params
+ (org-babel-parse-header-arguments
+ (org-babel-clean-text-properties
+ (mapconcat #'identity (cdr (split-string raw-header)) " "))))
+ (link (org-make-link-string
+ (concat
+ org-current-export-file
+ "::"
+ (nth 4 (ignore-errors (org-heading-components))))))
+ (export-buffer (current-buffer)))
;; bail if we couldn't get any info from the block
(when info
+ ;; resolve parameters in the original file so that headline
+ ;; and file-wide parameters are included
+ ;; attempt to go to the same heading in the original file
+ (set-buffer (get-file-buffer org-current-export-file))
+ (save-restriction
+ (org-open-link-from-string link)
+ (setf (nth 2 info)
+ (org-babel-merge-params
+ org-babel-default-header-args
+ (org-babel-params-from-buffer)
+ (org-babel-params-from-properties lang)
+ (if (boundp lang-headers) (eval lang-headers) nil)
+ raw-params)))
+ (set-buffer export-buffer)
;; expand noweb references in the original file
(setf (nth 1 info)
- (if (and (cdr (assoc :noweb params))
- (string= "yes" (cdr (assoc :noweb params))))
+ (if (and (cdr (assoc :noweb (nth 2 info)))
+ (string= "yes" (cdr (assoc :noweb (nth 2 info)))))
(org-babel-expand-noweb-references
info (get-file-buffer org-current-export-file))
(nth 1 info))))