Browse Source

org-export: Fill `org-export-current-backend' before pre-parsing hook

* contrib/lisp/org-export.el (org-export-as): Store current back-end
  in `org-export-current-backend' before running
  `org-export-before-parsing-hook'.
Nicolas Goaziou 13 years ago
parent
commit
507b3c937b
1 changed files with 7 additions and 1 deletions
  1. 7 1
      contrib/lisp/org-export.el

+ 7 - 1
contrib/lisp/org-export.el

@@ -2228,6 +2228,8 @@ Return the updated communication channel."
 ;; why file inclusion should be done before any structure can be
 ;; associated to the file, that is before parsing.
 
+(defvar org-current-export-file)	; Dynamically scoped
+(defvar org-export-current-backend)	; Dynamically scoped
 (defun org-export-as
   (backend &optional subtreep visible-only body-only ext-plist noexpand)
   "Transcode current Org buffer into BACKEND code.
@@ -2288,7 +2290,11 @@ Return code as a string."
 		       (let ((org-current-export-file buf))
 			 (org-export-blocks-preprocess)))
 		     (goto-char (point-min))
-		     (run-hooks 'org-export-before-parsing-hook)
+		     ;; Run hook with `org-export-current-backend' set
+		     ;; to BACKEND.
+		     (let ((org-export-current-backend backend))
+		       (run-hooks 'org-export-before-parsing-hook))
+		     ;; Eventually parse buffer.
 		     (org-element-parse-buffer nil visible-only)))))
 	;; 3. Call parse-tree filters to get the final tree.
 	(setq tree