diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-12-19 16:30:36 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-12-19 16:36:54 -0700 |
commit | 76661a853aff0a26414410a56e78924ef1103060 (patch) | |
tree | 4fcbee575bd6458ed8a42cb9cd15f35b19d48d85 | |
parent | d6fefb406ef08a2c6840372b7197876ee6fddc78 (diff) | |
download | org-mode-76661a853aff0a26414410a56e78924ef1103060.tar.gz |
org-mime: adding format specific pre-export hooks
Thanks to Niels Giesen for suggesting this change.
* contrib/lisp/org-mime.el (lambda): Adding format specific pre-export
hooks.
(org-mime-compose): Call pre-export hooks before export.
-rw-r--r-- | contrib/lisp/org-mime.el | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/contrib/lisp/org-mime.el b/contrib/lisp/org-mime.el index 4f250f6..9b369e6 100644 --- a/contrib/lisp/org-mime.el +++ b/contrib/lisp/org-mime.el @@ -85,6 +85,15 @@ :group 'org-mime :type 'hook) +(mapc (lambda (fmt) + (eval `(defcustom + ,(intern (concat "org-mime-pre-" fmt "-hook")) + nil + (concat "Hook to run before " fmt " export.\nFunctions " + "should take no arguments and will be run in a " + "buffer holding\nthe text to be exported.")))) + '("ascii" "org" "html" "html-ascii")) + ;; example hook, for setting a dark background in <pre style="background-color: #EEE;"> elements (defun org-mime-change-element-style (element style) "Set new default htlm style for <ELEMENT> elements in exported html." @@ -245,7 +254,15 @@ export that region, otherwise export the entire body." (require 'message) (message-mail to subject headers nil) (message-goto-body) - (let ((fmt (if (symbolp fmt) fmt (intern fmt)))) + (let* ((fmt (if (symbolp fmt) fmt (intern fmt))) + (hook (intern (concat "org-mime-pre-" (symbol-name fmt) "-hook"))) + (body (if (> (eval `(length ,hook)) 0) + (with-temp-buffer + (insert body) + (goto-char (point-min)) + (eval `(run-hooks ',hook)) + (buffer-string)) + body))) (cond ((eq fmt 'org) (insert (org-export-string (org-babel-trim body) 'org))) |