diff options
author | Xinglu Chen <public@yoctocell.xyz> | 2021-06-21 13:56:09 +0200 |
---|---|---|
committer | Xinglu Chen <public@yoctocell.xyz> | 2021-06-21 14:23:27 +0200 |
commit | a141b208ab4484c26ef7d6690c9b9b8da4f32920 (patch) | |
tree | f7c347aad7eaf6ed410f060874eaf32e1ebef526 | |
parent | e95230dcbb7059feebf3b0d5a92b0fa09a5c450c (diff) |
git-email: Support re-writing if header doesn’t already exist.
* git-email.el (git-email--rewrite-header-in-buffer): Check if header
is found before re-writing.
Signed-off-by: Xinglu Chen <public@yoctocell.xyz>
-rw-r--r-- | git-email.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/git-email.el b/git-email.el index 21769fd..17e3e0e 100644 --- a/git-email.el +++ b/git-email.el @@ -464,9 +464,13 @@ default behavior is to delete them after sending the message." (save-excursion (goto-char (point-min)) (let* ((case-fold-search t)) - (re-search-forward (concat "^" (capitalize header) ":") nil t ) - (delete-region (point) (point-at-eol)) - (insert " " value)))) + (if (re-search-forward (concat "^" (capitalize header) ":") nil t) + (progn + (delete-region (point) (point-at-eol)) + (insert " " value)) + (progn + (re-search-forward "^Subject: .*$") + (insert "\n" (concat (capitalize header) ": " value))))))) ;;;###autoload (defun git-email-rewrite-header (header value) |