diff --git a/init.el b/init.el index 6e80b41..ca0c507 100644 --- a/init.el +++ b/init.el @@ -796,7 +796,8 @@ org-attach-id-uuid-folder-format))) (setup ox ; org-export - (:also-load ox-md) + (:also-load +ox + ox-md) (:option org-export-coding-system 'utf-8-unix org-export-headline-levels 8 org-export-with-drawers nil @@ -804,8 +805,11 @@ org-export-with-smart-quotes t org-export-with-sub-superscripts t org-export-with-toc nil) + (with-eval-after-load 'ox + (+org-export-pre-hooks-insinuate)) + (add-hook '+org-export-pre-hook #'+flyspell-correct-buffer) (with-eval-after-load 'user-save - (advice-add 'org-export-as :before #'user-save-run-hooks))) + (add-hook '+org-export-pre-hook #'user-save-run-hooks))) (setup password-cache (:option password-cache t 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