Browse Source

org-mime: hooks run in org-mode buffer when composing an email

  Thanks to Ethan Ligon for suggesting this functionality.

  An example hook such as the following will record when emails have
  been composed

    (add-hook 'org-mime-send-subtree-hook
            (lambda ()
              (org-entry-put (point) "mail_composed" (current-time-string))))

* contrib/lisp/org-mime.el (org-mime-send-subtree-hook): Hooks run
  in the org-mode subtree when composing an email.
  (org-mime-send-buffer-hook): Hooks run in the org-mode buffer when
  composing an email.
Eric Schulte 14 years ago
parent
commit
61470f6ae1
1 changed files with 8 additions and 0 deletions
  1. 8 0
      contrib/lisp/org-mime.el

+ 8 - 0
contrib/lisp/org-mime.el

@@ -94,6 +94,12 @@
 			 "buffer holding\nthe text to be exported."))))
       '("ascii" "org" "html" "html-ascii"))
 
+(defcustom org-mime-send-subtree-hook nil
+  "Hook to run in the subtree in the Org-mode file before export.")
+
+(defcustom org-mime-send-buffer-hook nil
+  "Hook to run in the Org-mode file before export.")
+
 ;; 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."
@@ -223,6 +229,7 @@ export that region, otherwise export the entire body."
 (defun org-mime-send-subtree (&optional fmt)
   (save-restriction
     (org-narrow-to-subtree)
+    (run-hooks 'org-mime-send-subtree-hook)
     (let* ((file (buffer-file-name (current-buffer)))
 	   (subject (nth 4 (org-heading-components)))
 	   (to (org-entry-get nil "MAIL_TO"))
@@ -240,6 +247,7 @@ export that region, otherwise export the entire body."
 			`((cc . ,cc) (bcc . ,bcc))))))
 
 (defun org-mime-send-buffer (&optional fmt)
+  (run-hooks 'org-mime-send-buffer-hook)
   (let* ((region-p (org-region-active-p))
 	 (subject (org-export-grab-title-from-buffer))
          (file (buffer-file-name (current-buffer)))