From d2a63a1b178975c17d590dde7fabb48dd4aace65 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 13 Jan 2012 23:33:41 +0100 Subject: [PATCH] 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. --- lisp/ob-exp.el | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index f0fd3f46c..0a2316367 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -50,24 +50,21 @@ process." (declare (indent 1)) `(let* ((lang-headers (intern (concat "org-babel-default-header-args:" ,lang))) (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) - (when link + (when org-current-export-file ;; 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)) + (set-buffer (if (bufferp org-current-export-file) org-current-export-file + (get-file-buffer org-current-export-file))) (save-restriction - (condition-case nil - (let ((org-link-search-inhibit-query t)) - (org-open-link-from-string link)) - (error (when heading - (goto-char (point-min)) - (re-search-forward (regexp-quote heading) nil t)))) + (when heading + (condition-case nil + (let ((org-link-search-inhibit-query t)) + (org-link-search heading)) + (error (when heading + (goto-char (point-min)) + (re-search-forward (regexp-quote heading) nil t))))) (setq results ,@body)) (set-buffer export-buffer) results))) @@ -114,7 +111,9 @@ none ----- do not display either code or results upon export" (org-babel-noweb-wrap) "" (nth 1 info)) (if (org-babel-noweb-p (nth 2 info) :export) (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)))) (org-babel-exp-do-export info 'block hash))))) @@ -165,7 +164,9 @@ this template." (if (and (cdr (assoc :noweb params)) (string= "yes" (cdr (assoc :noweb params)))) (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))) (let ((code-replacement (save-match-data (org-babel-exp-do-export