diff options
author | Xinglu Chen <public@yoctocell.xyz> | 2021-06-21 14:57:22 +0200 |
---|---|---|
committer | Xinglu Chen <public@yoctocell.xyz> | 2021-06-21 15:13:52 +0200 |
commit | 1b2f4219e9375642491d490ce0c421f8ec966524 (patch) | |
tree | a28767148ea437b21e3d6cbf7b46ed23e6e9f740 /git-email.el | |
parent | e6a8567b4354aa585540cf8577b68d081cd52b16 (diff) |
git-email: Make it possible to customize message buffer names.
* git-email.el (git-email-generate-message-buffer): New defcustom.
(git-email-generate-message-buffer-name): New function
(git-email--send-files): Likewise.
(git-email-format-patch): Refactor to use ‘git-email--send-files’.
(git-email-send-email): Likewise.
* doc/git-email.texi (Miscellaneous): Document it.
Signed-off-by: Xinglu Chen <public@yoctocell.xyz>
Diffstat (limited to 'git-email.el')
-rw-r--r-- | git-email.el | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/git-email.el b/git-email.el index 487429a..0c58a59 100644 --- a/git-email.el +++ b/git-email.el @@ -157,6 +157,23 @@ If none of the functions return non-nil value, :group 'git-email :package-version '(git-email . "0.2.0")) +(defcustom git-email-generate-message-buffer + #'git-email-generate-message-buffer-name + "Function for generating the name of a message buffer. +The function must take three arguments: the type, the \"To\" +address, and the group name. See `message-generate-new-buffers' +for more information. + +By default it will be \"*git-email unsent patch to *** TO ADDRESS +HERE *** *\"." + :type '(choice (const nil) + (sexp :tag "unique" :format "unique\n" :value unique + :match (lambda (widget value) (memq value '(unique t)))) + (const unsent) + (const standard) + (function :format "\n %{%t%}: %v")) + :group 'git-email + :package-version '(git-email . "0.3.0")) ;; Remove Compiler warnings (declare-function dired-get-filename "dired.el") @@ -434,13 +451,18 @@ default behavior is to delete them after sending the message." (format "git format-patch %s %s" args range)) "\n"))))) - (dolist (file files) - (run-hooks 'git-email-pre-compose-email-hook) - (git-email--compose-email file) - (run-hooks 'git-email-post-compose-email-hook)) + (git-email--send-files files) (unless keep (mapc #'delete-file files)))) + +;;;; Misc + +(defun git-email-generate-message-buffer-name (_type address _group) + "Generate a buffer name that looks like this: + +\"* git-email unsent patch to *** TO ADDRESS HERE *** *\"" + (concat "*git-email unsent patch to " address " *")) ;;;; Operate on emails @@ -481,6 +503,14 @@ default behavior is to delete them after sending the message." (re-search-forward "^Subject: .*$") (insert "\n" (concat (capitalize header) ": " value))))))) +(defun git-email--send-files (files) + (dolist (file files) + (run-hooks 'git-email-pre-compose-email-hook) + (let ((message-generate-new-buffers + git-email-generate-message-buffer)) + (git-email--compose-email file)) + (run-hooks 'git-email-post-compose-email-hook))) + ;;;###autoload (defun git-email-rewrite-header (header value &optional append) "Re-write the value of HEADER to VALUE, if HEADER doesn't exist @@ -510,10 +540,7 @@ give you an address to send your patches to." (defun git-email-send-email (files) "Send FILES as patch(es) to someone using your MUA." (interactive (list (git-email--get-files))) - (dolist (file files) - (run-hooks 'git-email-pre-compose-email-hook) - (git-email--compose-email file) - (run-hooks 'git-email-post-compose-email-hook))) + (git-email--send-files files)) (provide 'git-email) ;;; git-email.el ends here |