From 1b0778eb9dec87217423e2182a2f64113ccc257b Mon Sep 17 00:00:00 2001 From: yoctocell Date: Mon, 18 Jan 2021 12:35:04 +0100 Subject: Move cursor to "to" address if empty The cursor will be placed at the "to" header if it is empty when composing a message. --- git-email.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'git-email.el') diff --git a/git-email.el b/git-email.el index 5b72b33..0c55183 100644 --- a/git-email.el +++ b/git-email.el @@ -67,8 +67,10 @@ (defcustom git-email-headers '(subject from in-reply-to message-id references) "List of headers that should get inserted into the message buffer. -The 'to' address will always be inserted based on the 'sendemail.to' variable -in you git config. If the variable is not set, the 'to' address will be empty." + +The 'to' address will always be inserted based on the +'sendemail.to' variable in you git config. If the variable is +not set, the 'to' address will be empty." :group 'git-email :type '(symbol)) @@ -240,7 +242,7 @@ them into the message buffer." (sendemail-to (shell-command-to-string "git config --list | grep sendemail.to")) (to (if (string-equal sendemail-to "") - "" + "*** TO ADDRESS HERE ***" (substring sendemail-to 13 -1))) ; Remove newline (diff (git-email--extract-diff patch-file))) (funcall git-email-compose-email-function to @@ -257,8 +259,9 @@ them into the message buffer." (save-excursion (insert (git-email--fontify-using-faces (git-email--fontify-diff diff))))) - ;; Jump to subject if it is a cover letter - (when (re-search-backward "\\*\\*\\* SUBJECT HERE \\*\\*\\*" nil t) + ;; Jump to subject or 'to' address if they are emtpy + (when (or (re-search-backward "\\*\\*\\* TO ADDRESS HERE \\*\\*\\*" nil t) + (re-search-backward "\\*\\*\\* SUBJECT HERE \\*\\*\\*" nil t)) (kill-line)))) ;;;; Format patches -- cgit v1.2.3