aboutsummaryrefslogtreecommitdiff
path: root/git-email.el
diff options
context:
space:
mode:
Diffstat (limited to 'git-email.el')
-rw-r--r--git-email.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/git-email.el b/git-email.el
index 50e5774..c5ee138 100644
--- a/git-email.el
+++ b/git-email.el
@@ -156,10 +156,12 @@ Extracts the relevant headers and the diff from the PATCH-FILE and inserts
them into the message buffer."
(let* ((default-directory (cdr (project-current)))
(headers (git-email--extract-headers patch-file))
+ ;; Remove empty headers.
(used-headers (seq-filter
(lambda (header)
(not (string-equal (car (cdr header)) "")))
headers))
+ ;; Get 'to' address from git.
(sendemail-to
(shell-command-to-string "git config --list | grep sendemail.to"))
(to (if (string-equal sendemail-to "")
@@ -167,13 +169,17 @@ them into the message buffer."
(substring sendemail-to 13 -1))) ; Remove newline
(diff (git-email--extract-diff patch-file)))
(funcall git-email-compose-email-function to (cadr (assoc 'subject used-headers))
+ ;; Remove 'subject' header, otherwise two subject headers will be
+ ;; inserted.
(seq-filter 'git-email--remove-subject used-headers))
(goto-char (point-min))
+ ;; Insert diff at the beginning of the body
(let ((body (or (re-search-forward "<#part \\(encrypt\\|sign\\)=.*mime>" nil t)
(re-search-forward "--text follows this line--" nil t))))
(goto-char (+ body 1))
(save-excursion
(insert diff)))
+ ;; Jump to subject if it is a cover letter
(when (re-search-backward "\\*\\*\\* SUBJECT HERE \\*\\*\\*" nil t)
(kill-line))))