summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <eric.schulte@gmx.com>2012-01-15 10:46:48 -0700
committerEric Schulte <eric.schulte@gmx.com>2012-02-03 09:35:57 -0700
commitc55718c3777eb5cb01c0b98b63dae9b378d38209 (patch)
tree593c1e16c30e88b6b1e738eb234e7952463557f3
parentd2a63a1b178975c17d590dde7fabb48dd4aace65 (diff)
downloadorg-mode-c55718c3777eb5cb01c0b98b63dae9b378d38209.tar.gz
wrapping new org-current-export-file -> buffer login into a single function
* lisp/ob-exp.el (org-babel-exp-get-export-buffer): Access current export buffer. (org-babel-exp-in-export-file): Access current export buffer. (org-babel-exp-src-block): Access current export buffer. (org-babel-exp-inline-src-blocks): Access current export buffer. Conflicts: lisp/ob-exp.el (org-babel-exp-in-export-file): Resolving conflicts.
-rw-r--r--lisp/ob-exp.el24
1 files changed, 14 insertions, 10 deletions
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 0a23163..d069b2d 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -46,17 +46,25 @@ process."
:type 'boolean)
(put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil)))
+(defun org-babel-exp-get-export-buffer ()
+ "Return the current export buffer if possible."
+ (cond
+ ((bufferp org-current-export-file) org-current-export-file)
+ (org-current-export-file (get-file-buffer org-current-export-file))
+ ('otherwise
+ (error "Requested export buffer when `org-current-export-file' is nil"))))
+
(defmacro org-babel-exp-in-export-file (lang &rest body)
(declare (indent 1))
`(let* ((lang-headers (intern (concat "org-babel-default-header-args:" ,lang)))
(heading (nth 4 (ignore-errors (org-heading-components))))
- (export-buffer (current-buffer)) results)
- (when org-current-export-file
+ (export-buffer (current-buffer))
+ (original-buffer (org-babel-exp-get-export-buffer)) results)
+ (when original-buffer
;; 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 (if (bufferp org-current-export-file) org-current-export-file
- (get-file-buffer org-current-export-file)))
+ (set-buffer original-buffer)
(save-restriction
(when heading
(condition-case nil
@@ -111,9 +119,7 @@ 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 (if (bufferp org-current-export-file)
- org-current-export-file
- (get-file-buffer org-current-export-file)))
+ info (org-babel-exp-get-export-buffer))
(nth 1 info))))
(org-babel-exp-do-export info 'block hash)))))
@@ -164,9 +170,7 @@ this template."
(if (and (cdr (assoc :noweb params))
(string= "yes" (cdr (assoc :noweb params))))
(org-babel-expand-noweb-references
- info (if (bufferp org-current-export-file)
- org-current-export-file
- (get-file-buffer org-current-export-file)))
+ info (org-babel-exp-get-export-buffer))
(nth 1 info)))
(let ((code-replacement (save-match-data
(org-babel-exp-do-export