diff options
author | yoctocell <public@yoctocell.xyz> | 2021-01-04 22:04:01 +0100 |
---|---|---|
committer | yoctocell <public@yoctocell.xyz> | 2021-01-04 22:04:01 +0100 |
commit | 0a72c831da37e9f7854fa4ccaf5fdec84328a768 (patch) | |
tree | 65653c252498a737ee611eeb8daccb4798742866 /git-email.el | |
parent | 7d768ca221e7d7235bee4bc6573791c39934357b (diff) |
Add comments
Explain some parts in more detail.
* git-email.el (git-email--compose-email):
Diffstat (limited to 'git-email.el')
-rw-r--r-- | git-email.el | 6 |
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)))) |