summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-10-08 11:14:45 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-10-14 10:39:10 -0700
commitcda8e5551e105f7a66f605419bcdc8bbceea7c6a (patch)
treea628dc6d2d3eee66b438f3705789ef5f61c33cd4
parent16a343002f85259c5e43e963a95d7cd21bd590be (diff)
downloaddotfiles-cda8e5551e105f7a66f605419bcdc8bbceea7c6a.tar.gz
add spw/git-format-patch
-rw-r--r--.emacs.d/init.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index ef2920ca..40429e9d 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -2482,6 +2482,28 @@ Called by '~/src/dotfiles/bin/emacsclient --spw/update-environment'."
(insert "#+title: ")))
(spw/feature-define-keys org "\C-z\C-t" spw/org-title)
+(defun spw/git-format-patch (args &optional new)
+ "Git-specific `vc-prepare-patch' w/ non-nil `vc-prepare-patches-separately'.
+We want to take advantage of the -<n> and -v arguments to
+git-format-patch(1), and also of how it numbers the patches."
+ (interactive "sgit format-patch \nP")
+ (let* ((patches-from default-directory)
+ (v (and (string-match "\\_<-\\(?:v\\|-reroll-count\\)\\([0-9]+\\)\\b"
+ args)
+ (match-string 1 args)))
+ (prefix (format "[%sPATCH%s] "
+ (if (string-match "\\_<--rfc\\b" args) "RFC " "")
+ (if v (concat " v" v) ""))))
+ (compose-mail nil prefix nil (not new))
+ (save-excursion
+ (goto-char (point-max))
+ (terpri (current-buffer) t)
+ (mapc #'mail-add-attachment
+ (let ((default-directory patches-from))
+ (apply #'process-lines
+ "git" "format-patch"
+ (split-string-and-unquote args)))))))
+
;;;; Terminal emulation