From 0a72c831da37e9f7854fa4ccaf5fdec84328a768 Mon Sep 17 00:00:00 2001 From: yoctocell Date: Mon, 4 Jan 2021 22:04:01 +0100 Subject: Add comments Explain some parts in more detail. * git-email.el (git-email--compose-email): --- git-email.el | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'git-email.el') 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)))) -- cgit v1.2.3