aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinglu Chen <public@yoctocell.xyz>2021-06-21 13:46:25 +0200
committerXinglu Chen <public@yoctocell.xyz>2021-06-21 14:23:25 +0200
commite95230dcbb7059feebf3b0d5a92b0fa09a5c450c (patch)
tree78e51ae3e14a27828945bcac4ffdbcd2965b83c9
parentda5f0cc9dbda27cf79c1b7779332da375fd0bb89 (diff)
git-email: Add ablitiy to re-write header.
* git-email.el (git-email--rewrite-header-in-buffer): New function. (git-email-rewrite-header): Likewise. Signed-off-by: Xinglu Chen <public@yoctocell.xyz>
-rw-r--r--git-email.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/git-email.el b/git-email.el
index fedd03d..21769fd 100644
--- a/git-email.el
+++ b/git-email.el
@@ -459,6 +459,35 @@ default behavior is to delete them after sending the message."
(funcall git-email-send-email-function))
buffers)))
+(defun git-email--rewrite-header-in-buffer (buffer header value)
+ (switch-to-buffer buffer)
+ (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))))
+
+;;;###autoload
+(defun git-email-rewrite-header (header value)
+ "Re-write the value of HEADER to VALUE, if HEADER doesn't exist
+yet, just set it to VALUE.
+
+This is mainly useful if you forgot to Cc someone when using
+`git-email-format-patch', or if you are waiting for Debbugs to
+give you an address to send your patches to."
+ (interactive
+ (list (completing-read "Header to re-write: "
+ git-email-headers)
+ (read-from-minibuffer "Set header to: ")))
+ (let ((buffers (message-buffers))
+ (start-buffer (current-buffer)))
+ (save-excursion
+ (mapc (lambda (buffer)
+ (git-email--rewrite-header-in-buffer buffer header value))
+ buffers))
+ (switch-to-buffer start-buffer)))
+
;;;###autoload
(defun git-email-send-email (files)
"Send FILES as patch(es) to someone using your MUA."