aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git-email.el61
1 files changed, 59 insertions, 2 deletions
diff --git a/git-email.el b/git-email.el
index ee65fd5..21f7c79 100644
--- a/git-email.el
+++ b/git-email.el
@@ -41,6 +41,7 @@
;;; Code:
(require 'project)
+(require 'message)
(defgroup git-email nil
"Work with git and email."
@@ -51,6 +52,18 @@
:group 'git-email
:type 'symbol)
+(defcustom git-email-pre-compose-email-hook
+ '(git-email--set-message-header-format)
+ "A list of functions called before running `git-email--compose-message'."
+ :type 'hook
+ :group 'git-email)
+
+(defcustom git-email-post-compose-email-hook
+ '(git-email--reset-message-header-format)
+ "A list of functions called after running `git-email--compose-message'."
+ :type 'hook
+ :group 'git-email)
+
(defcustom git-email-headers
'("subject" "from" "in-reply-to" "message-id")
"List of headers that should get inserted into the message buffer.
@@ -83,6 +96,47 @@ want."
:group 'git-email
:type '(string))
+(defun git-email--set-message-header-format ()
+ "Set `message-header-format-alist' to parse the 'references' header correctly.
+This will be run as a `git-email-pro-compose-email-hook' hook."
+ (setq message-header-format-alist
+ '((From)
+ (Newsgroups)
+ (To)
+ (Cc)
+ (Subject)
+ (In-Reply-To)
+ (Fcc)
+ (Bcc)
+ (Date)
+ (Organization)
+ (Distribution)
+ (Lines)
+ (Expires)
+ (Message-ID)
+ (References)
+ (User-Agent))))
+
+(defun git-email--reset-message-header-format ()
+ "Reset `message-header-format-alist' to the its default value."
+ (setq message-header-format-alist
+ '((From)
+ (Newsgroups)
+ (To)
+ (Cc)
+ (Subject)
+ (In-Reply-To)
+ (Fcc)
+ (Bcc)
+ (Date)
+ (Organization)
+ (Distribution)
+ (Lines)
+ (Expires)
+ (Message-ID)
+ (References . message-shorten-references)
+ (User-Agent))))
+
(defun git-email--extract-header (header)
"Extract HEADER from current buffer."
(goto-char (point-min))
@@ -150,9 +204,12 @@ If no marks are found, return the filename at point."
(defun git-email-send-email ()
"Send patch(es) to someone."
(interactive)
+ (run-hooks 'git-email-pre-compose-email-hook)
(let ((files (git-email--get-filenames)))
- (dolist (file files)
- (git-email--compose-email file))))
+ (prog1
+ (dolist (file files)
+ (git-email--compose-email file))
+ (run-hooks 'git-email-post-compose-email-hook))))
(defun git-email--compose-email (patch-file)
"Given a PATCH-FILE, compose an email.