diff options
author | Case Duckworth | 2022-04-24 17:00:36 -0500 |
---|---|---|
committer | Case Duckworth | 2022-04-24 17:00:36 -0500 |
commit | 3f925fc0e3ae352fb15ad93e6c169a0307aaffc7 (patch) | |
tree | ef5820ef2933bf7742edae6cd09f45f6a5e697f9 /lisp | |
parent | Correction: uh, not a typo but whatever (diff) | |
download | emacs-3f925fc0e3ae352fb15ad93e6c169a0307aaffc7.tar.gz emacs-3f925fc0e3ae352fb15ad93e6c169a0307aaffc7.zip |
Add +org-export-pre-hook to prepare the buffer before export
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+ox.el | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lisp/+ox.el b/lisp/+ox.el new file mode 100644 index 0000000..8748a55 --- /dev/null +++ b/lisp/+ox.el | |||
@@ -0,0 +1,29 @@ | |||
1 | ;;; +ox.el --- org-export helpers -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;;; Code: | ||
6 | |||
7 | (require 'ox) | ||
8 | |||
9 | ;;; Run hooks before doing any exporting at all | ||
10 | |||
11 | (defcustom +org-export-pre-hook nil | ||
12 | "Functions to run /before/ `org-export-as' does anything. | ||
13 | These will run on the buffer about to be exported, NOT a copy." | ||
14 | :type 'hook) | ||
15 | |||
16 | (defun +org-export-pre-run-hooks (&rest _) | ||
17 | "Run hooks in `+org-export-pre-hook'." | ||
18 | (run-hooks '+org-export-pre-hook)) | ||
19 | |||
20 | (defun +org-export-pre-hooks-insinuate () | ||
21 | "Advise `org-export-as' to run `+org-export-pre-hook'." | ||
22 | (advice-add 'org-export-as :before #'+org-export-pre-run-hooks)) | ||
23 | |||
24 | (defun +org-export-pre-hooks-remove () | ||
25 | "Remove pre-hook advice on `org-export-as'." | ||
26 | (advice-remove 'org-export-as #'+org-export-pre-run-hooks)) | ||
27 | |||
28 | (provide '+ox) | ||
29 | ;;; +ox.el ends here | ||