From 3f925fc0e3ae352fb15ad93e6c169a0307aaffc7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 24 Apr 2022 17:00:36 -0500 Subject: Add +org-export-pre-hook to prepare the buffer before export --- lisp/+ox.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lisp/+ox.el (limited to 'lisp') 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 @@ +;;; +ox.el --- org-export helpers -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + +(require 'ox) + +;;; Run hooks before doing any exporting at all + +(defcustom +org-export-pre-hook nil + "Functions to run /before/ `org-export-as' does anything. +These will run on the buffer about to be exported, NOT a copy." + :type 'hook) + +(defun +org-export-pre-run-hooks (&rest _) + "Run hooks in `+org-export-pre-hook'." + (run-hooks '+org-export-pre-hook)) + +(defun +org-export-pre-hooks-insinuate () + "Advise `org-export-as' to run `+org-export-pre-hook'." + (advice-add 'org-export-as :before #'+org-export-pre-run-hooks)) + +(defun +org-export-pre-hooks-remove () + "Remove pre-hook advice on `org-export-as'." + (advice-remove 'org-export-as #'+org-export-pre-run-hooks)) + +(provide '+ox) +;;; +ox.el ends here -- cgit 1.4.1-21-gabe81