ob-exp: Allow org-current-export-file to contain a buffer name

* lisp/ob-exp.el (org-babel-exp-in-export-file,
org-babel-exp-src-block, org-babel-exp-inline-src-blocks): Allow
org-current-export-file to contain a buffer.

This allows to resolve references from a buffer not visiting any file
(i.e. a temporary buffer) during export process.

Conflicts:

	lisp/ob-exp.el (org-babel-exp-in-export-file): Allow
	org-current-export-file to contain a buffer name.
This commit is contained in:
Nicolas Goaziou 2012-01-13 23:33:41 +01:00 committed by Eric Schulte
parent 9b820def5b
commit d2a63a1b17
1 changed files with 16 additions and 15 deletions

View File

@ -50,24 +50,21 @@ process."
(declare (indent 1)) (declare (indent 1))
`(let* ((lang-headers (intern (concat "org-babel-default-header-args:" ,lang))) `(let* ((lang-headers (intern (concat "org-babel-default-header-args:" ,lang)))
(heading (nth 4 (ignore-errors (org-heading-components)))) (heading (nth 4 (ignore-errors (org-heading-components))))
(link (when org-current-export-file
(org-make-link-string
(if heading
(concat org-current-export-file "::" heading)
org-current-export-file))))
(export-buffer (current-buffer)) results) (export-buffer (current-buffer)) results)
(when link (when org-current-export-file
;; resolve parameters in the original file so that ;; resolve parameters in the original file so that
;; headline and file-wide parameters are included, attempt ;; headline and file-wide parameters are included, attempt
;; to go to the same heading in the original file ;; to go to the same heading in the original file
(set-buffer (get-file-buffer org-current-export-file)) (set-buffer (if (bufferp org-current-export-file) org-current-export-file
(get-file-buffer org-current-export-file)))
(save-restriction (save-restriction
(condition-case nil (when heading
(let ((org-link-search-inhibit-query t)) (condition-case nil
(org-open-link-from-string link)) (let ((org-link-search-inhibit-query t))
(error (when heading (org-link-search heading))
(goto-char (point-min)) (error (when heading
(re-search-forward (regexp-quote heading) nil t)))) (goto-char (point-min))
(re-search-forward (regexp-quote heading) nil t)))))
(setq results ,@body)) (setq results ,@body))
(set-buffer export-buffer) (set-buffer export-buffer)
results))) results)))
@ -114,7 +111,9 @@ none ----- do not display either code or results upon export"
(org-babel-noweb-wrap) "" (nth 1 info)) (org-babel-noweb-wrap) "" (nth 1 info))
(if (org-babel-noweb-p (nth 2 info) :export) (if (org-babel-noweb-p (nth 2 info) :export)
(org-babel-expand-noweb-references (org-babel-expand-noweb-references
info (get-file-buffer org-current-export-file)) info (if (bufferp org-current-export-file)
org-current-export-file
(get-file-buffer org-current-export-file)))
(nth 1 info)))) (nth 1 info))))
(org-babel-exp-do-export info 'block hash))))) (org-babel-exp-do-export info 'block hash)))))
@ -165,7 +164,9 @@ this template."
(if (and (cdr (assoc :noweb params)) (if (and (cdr (assoc :noweb params))
(string= "yes" (cdr (assoc :noweb params)))) (string= "yes" (cdr (assoc :noweb params))))
(org-babel-expand-noweb-references (org-babel-expand-noweb-references
info (get-file-buffer org-current-export-file)) info (if (bufferp org-current-export-file)
org-current-export-file
(get-file-buffer org-current-export-file)))
(nth 1 info))) (nth 1 info)))
(let ((code-replacement (save-match-data (let ((code-replacement (save-match-data
(org-babel-exp-do-export (org-babel-exp-do-export