From 39359f400d567562093e4171f839f8ec8df8f4b4 Mon Sep 17 00:00:00 2001 From: yoctocell Date: Wed, 6 Jan 2021 17:25:10 +0100 Subject: Make `git-email-apply-patch' more configurable The user can supply a custom function and command to used instead of the default ones. * git-email.el (git-email-apply-patch-function): (git-email-apply-patch-command): (git-email--shell-command-on-body): (git-email-apply-patch): --- git-email.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'git-email.el') diff --git a/git-email.el b/git-email.el index 244f44e..d8f3069 100644 --- a/git-email.el +++ b/git-email.el @@ -96,6 +96,20 @@ in you git config. If the variable is not set, the 'to' address will be empty." :type 'int :group 'git-email) +(defcustom git-email-apply-patch-function + 'git-email--shell-command-on-body + "Function that executes a shell command on the body of the message. +This function should take one argument, it should be the shell command to +execute. By default it is determined by the `git-email-apply-patch-command' +variable." + :type 'symbol + :group 'git-email) + +(defcustom git-email-apply-patch-command "git am" + "Command to run to apply the patch." + :type 'string + :group 'git-email) + ;; Compile warnings (declare-function dired-get-filename "dired.el") (declare-function dired-map-over-marks "dired.el") @@ -111,6 +125,10 @@ in you git config. If the variable is not set, the 'to' address will be empty." (funcall git-email-send-email-function)) buffers))) +(defun git-email--shell-command-on-body (command) + "Get the body of the message in the current buffer and run COMMAND on it." + (shell-command-on-region (point-min) (point-max) command)) + (defun git-email--extract-header (header) "Extract HEADER from current buffer." (goto-char (point-min)) @@ -232,7 +250,8 @@ If no marks are found, return the filename at point." (interactive (list (project-prompt-project-dir))) (let ((default-directory project)) (push (list project) project--list) - (shell-command-on-region (point-min) (point-max) "git am"))) + (funcall git-email-apply-patch-function + git-email-apply-patch-command))) ;;;###autoload (defun git-email-send-email () -- cgit v1.2.3