From: Sean Whitton <spwhitton@spwhitton.name>
To: 60147@debbugs.gnu.org
Cc: philipk@posteo.net
Subject: bug#60147: 30.0.50; vc-prepare-patch: Add numbered patch file names
Date: Sat, 17 Dec 2022 05:40:58 +0000 [thread overview]
Message-ID: <Y51Wau+ncCxe3D+q@athena.silentflame.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
X-debbugs-cc: philipk@posteo.net
Hello,
If you receive a message generated by vc-prepare-patch and then you save all
the attachments to a directory, you lose any indication of the order in which
the patches are meant to be applied.
git-format-patch(1) numbers the patch files it saves. Thus, with most mail
clients, when the recipient saves all the attachments to a local directory,
they'll be ordered. I think it would be useful for vc-prepare-patch to do
something similar. Please find a patch attached.
--
Sean Whitton
[-- Attachment #2: 0001-vc-prepare-patch-Number-the-attached-patches.patch --]
[-- Type: text/x-diff, Size: 3767 bytes --]
From 226e689b1183a34f3b611185201416e4f3205304 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhitton@spwhitton.name>
Date: Fri, 16 Dec 2022 22:34:52 -0700
Subject: [PATCH] vc-prepare-patch: Number the attached patches
* lisp/gnus/mml.el (mml-attach-buffer): New FILENAME argument.
* lisp/vc/vc.el (vc-prepare-patch): When vc-prepare-patches-separately
is nil, generate file names for the attached patches. The file names
begin with numbers indicating the ordering of the patches.
---
lisp/gnus/mml.el | 13 ++++++++-----
lisp/vc/vc.el | 26 +++++++++++++++++++++-----
2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el
index ebd0adf2e25..dc86fe6db96 100644
--- a/lisp/gnus/mml.el
+++ b/lisp/gnus/mml.el
@@ -1484,10 +1484,12 @@ mml-dnd-attach-file
(setq disposition (mml-minibuffer-read-disposition type nil file)))
(mml-attach-file file type description disposition)))))
-(defun mml-attach-buffer (buffer &optional type description disposition)
+(defun mml-attach-buffer (buffer &optional type description disposition filename)
"Attach a buffer to the outgoing MIME message.
BUFFER is the name of the buffer to attach. See
-`mml-attach-file' for details of operation."
+`mml-attach-file' regarding TYPE, DESCRIPTION and DISPOSITION.
+FILENAME is a suggested file name for the attachment should a
+recipient wish to save a copy separate from the message."
(interactive
(let* ((buffer (read-buffer "Attach buffer: "))
(type (mml-minibuffer-read-type buffer "text/plain"))
@@ -1497,9 +1499,10 @@ mml-attach-buffer
;; If in the message header, attach at the end and leave point unchanged.
(let ((head (unless (message-in-body-p) (point))))
(if head (goto-char (point-max)))
- (mml-insert-empty-tag 'part 'type type 'buffer buffer
- 'disposition disposition
- 'description description)
+ (apply #'mml-insert-empty-tag
+ 'part 'type type 'buffer buffer
+ 'disposition disposition 'description description
+ (and filename `(filename ,filename)))
;; When using Mail mode, make sure it does the mime encoding
;; when you send the message.
(or (eq mail-user-agent 'message-user-agent)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 690c907c77e..ed10909fee8 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3466,11 +3466,27 @@ vc-prepare-patch
(rfc822-goto-eoh)
(forward-line)
(save-excursion
- (dolist (patch patches)
- (mml-attach-buffer (buffer-name (plist-get patch :buffer))
- "text/x-patch"
- (plist-get patch :subject)
- "attachment")))
+ (let ((i 0))
+ (dolist (patch patches)
+ (let* ((patch-subject (plist-get patch :subject))
+ (stripped-subject
+ (replace-regexp-in-string
+ "^\\[.*PATCH.*\\]\\s-*" "" patch-subject))
+ (filename
+ (concat
+ (string-trim
+ (replace-regexp-in-string
+ "\\W" "-" (if (length> stripped-subject 50)
+ (substring stripped-subject 0 50)
+ stripped-subject))
+ "-+" "-+")
+ ".patch")))
+ (mml-attach-buffer
+ (buffer-name (plist-get patch :buffer))
+ "text/x-patch"
+ patch-subject
+ "attachment"
+ (format "%04d-%s" (cl-incf i) filename))))))
(open-line 2)))))
(defun vc-default-responsible-p (_backend _file)
--
2.30.2
next reply other threads:[~2022-12-17 5:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-17 5:40 Sean Whitton [this message]
2022-12-17 9:33 ` bug#60147: 30.0.50; vc-prepare-patch: Add numbered patch file names Philip Kaludercic
2022-12-18 0:33 ` Sean Whitton
2022-12-18 10:45 ` Philip Kaludercic
2022-12-20 0:17 ` Sean Whitton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y51Wau+ncCxe3D+q@athena.silentflame.com \
--to=spwhitton@spwhitton.name \
--cc=60147@debbugs.gnu.org \
--cc=philipk@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).