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 | |
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>
-rw-r--r-- | doc/git-email.texi | 9 | ||||
-rw-r--r-- | git-email.el | 43 |
2 files changed, 44 insertions, 8 deletions
diff --git a/doc/git-email.texi b/doc/git-email.texi index cd4ebfd..632e29e 100644 --- a/doc/git-email.texi +++ b/doc/git-email.texi @@ -325,6 +325,15 @@ revision of under point if you are in a VC log buffer. @samp{git-email-get-current-project-functions} is a hook that is executed to get the path of the current project. The path must include a trailing @samp{/}. + +@vindex git-email-generate-message-buffer +@item +@code{git-email-generate-message-buffer} controls how message buffer +names are generated. See the documentation for +@code{message-generate-new-buffers} for more information. + +By default the name will have the following format @samp{git-email +unsent patch to *** TO ADDRESS HERE *** *}. @end itemize @node Integration with other packages 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 |