summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-08-24 10:06:14 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-08-24 10:10:44 +0200
commitcced6735a77bb2c7caf0681fd3fb05ea0ba31ef4 (patch)
tree596a82e8937dfcb1eaa9a73299cd40ac5da53902
parentcc839259a4561210374f4c1c7ba7933e4455aae7 (diff)
downloadorg-mode-cced6735a77bb2c7caf0681fd3fb05ea0ba31ef4.tar.gz
org-export: Run export hook with current back-end as argument
* contrib/lisp/org-export.el (org-export-as): Run export hook with current back-end as argument. * testing/lisp/test-org-export.el: Update test.
-rw-r--r--contrib/lisp/org-export.el16
-rw-r--r--testing/lisp/test-org-export.el2
2 files changed, 11 insertions, 7 deletions
diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el
index e4da913..57bbc43 100644
--- a/contrib/lisp/org-export.el
+++ b/contrib/lisp/org-export.el
@@ -2076,10 +2076,14 @@ Any element in `:ignore-list' will be skipped when using
(defvar org-export-before-parsing-hook nil
"Hook run before parsing an export buffer.
+
This is run after include keywords have been expanded and Babel
code executed, on a copy of original buffer's area being
exported. Visibility is the same as in the original one. Point
-is left at the beginning of the new one.")
+is left at the beginning of the new one.
+
+Every function in this hook will be called with one argument: the
+back-end currently used, as a symbol.")
;;;; Special Filters
@@ -2503,7 +2507,6 @@ Return the updated communication channel."
;; 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.
@@ -2561,10 +2564,11 @@ Return code as a string."
(let ((org-current-export-file buf))
(org-export-blocks-preprocess)))
(goto-char (point-min))
- ;; Run hook with `org-export-current-backend' set
- ;; to BACKEND.
- (let ((org-export-current-backend backend))
- (run-hooks 'org-export-before-parsing-hook))
+ ;; Run hook
+ ;; `org-export-before-parsing-hook'. with current
+ ;; back-end as argument.
+ (run-hook-with-args
+ 'org-export-before-parsing-hook backend)
;; Eventually parse buffer.
(org-element-parse-buffer nil visible-only)))))
;; 3. Call parse-tree filters to get the final tree.
diff --git a/testing/lisp/test-org-export.el b/testing/lisp/test-org-export.el
index 56b351e..7ef5789 100644
--- a/testing/lisp/test-org-export.el
+++ b/testing/lisp/test-org-export.el
@@ -407,7 +407,7 @@ body\n")))
(org-test-with-backend test
(org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2"
(let ((org-export-before-parsing-hook
- '((lambda ()
+ '((lambda (backend)
(org-map-entries
(lambda ()
(delete-region (point) (progn (forward-line) (point)))))))))