aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git-email.el31
1 files changed, 19 insertions, 12 deletions
diff --git a/git-email.el b/git-email.el
index 20b9400..3d3d71b 100644
--- a/git-email.el
+++ b/git-email.el
@@ -300,18 +300,25 @@ so might not always work."
Extracts the relevant headers and the diff from the PATCH-FILE and inserts
them into the message buffer."
(let* ((headers (git-email--extract-headers patch-file))
- ;; Remove empty headers.
- (used-headers (seq-filter
- (lambda (header)
- (not (string-equal (car (cdr header)) "")))
- headers))
- (sendemail-to (run-hook-with-args-until-success
- 'git-email-get-to-address-functions))
- ;; Get 'to' address from git.
- (to (if (string-equal sendemail-to "")
- "*** TO ADDRESS HERE ***"
- sendemail-to))
- (diff (git-email--extract-diff patch-file)))
+ ;; Remove empty headers.
+ (used-headers (seq-filter
+ (lambda (header)
+ (not (string-equal (cdr header) "")))
+ headers))
+ (to-address (seq-position used-headers
+ 'to
+ (lambda (a b)
+ (equal (car a) b))))
+ ;; Don't insert 'to' address if the patch already contains one.
+ (sendemail-to (if to-address
+ (cdr (nth to-address used-headers))
+ (run-hook-with-args-until-success
+ 'git-email-get-to-address-functions)))
+ (to (if (string-equal sendemail-to "")
+ "*** TO ADDRESS HERE ***"
+ sendemail-to))
+ (diff (git-email--extract-diff patch-file)))
+ (print to-address)
(funcall git-email-compose-email-function to
;; Remove 'subject' header, otherwise two subject headers will be
;; inserted.