From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#60147: 30.0.50; vc-prepare-patch: Add numbered patch file names Date: Sat, 17 Dec 2022 09:33:20 +0000 Message-ID: <87y1r64bof.fsf@posteo.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18513"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60147@debbugs.gnu.org To: Sean Whitton Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 17 10:34:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p6TaF-0004b7-UX for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Dec 2022 10:34:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6Ta1-0005r3-Ay; Sat, 17 Dec 2022 04:34:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6TZy-0005p3-JB for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 04:34:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p6TZy-0002EB-BT for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 04:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p6TZx-0005Ww-Ud for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 04:34:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Dec 2022 09:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60147 X-GNU-PR-Package: emacs Original-Received: via spool by 60147-submit@debbugs.gnu.org id=B60147.167126960821247 (code B ref 60147); Sat, 17 Dec 2022 09:34:01 +0000 Original-Received: (at 60147) by debbugs.gnu.org; 17 Dec 2022 09:33:28 +0000 Original-Received: from localhost ([127.0.0.1]:54847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6TZP-0005Wb-Ib for submit@debbugs.gnu.org; Sat, 17 Dec 2022 04:33:28 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:32947) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6TZM-0005WT-4O for 60147@debbugs.gnu.org; Sat, 17 Dec 2022 04:33:26 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2D6F3240104 for <60147@debbugs.gnu.org>; Sat, 17 Dec 2022 10:33:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1671269598; bh=hJ9UD/FPu6W/IYlZlacUwGAvdXgfjDd9d/Y242HdCUY=; h=From:To:Cc:Subject:Date:From; b=ZuBFtgiPCdPynxIVqcOK3sj4a/OmqkGG5zdKT5tWQmx8epJLAm6zZKDjCSWC/1wHd XERKfDHt4OafNvUfuxq7wGCV6+wLyRIbkEKP+2aET0U47Bxq15baZbxz8bS7sHtuGL abd9mDrwXnFZDaK6L/W5MI9r4keaBHo3UNLer9NNcBq/A1sG4I/cLWvBGbL6ThEh6M yD+T9raxDSXo2hYFa/lRA4hWHW5lmeJZj5oT4mcGdFo5Bm51JxK51nT7ne1YHrvo6h QlMFMjY/kQS63ivJRCupd8HEIlAVNCHyk3FiTRdWhcAQMJo4TKNLETk166Sv7ygEOJ 4Ql/NDJ5kfDLA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NZ13x3qZ3z9rxD; Sat, 17 Dec 2022 10:33:16 +0100 (CET) In-Reply-To: (Sean Whitton's message of "Sat, 17 Dec 2022 05:40:58 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251265 Archived-At: Sean Whitton writes: > 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. This sounds good, find my comments below. > -- > Sean Whitton > > From 226e689b1183a34f3b611185201416e4f3205304 Mon Sep 17 00:00:00 2001 > From: Sean Whitton > 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)) I think using a \` instead of ^ would be more robust. > + (filename > + (concat > + (string-trim > + (replace-regexp-in-string > + "\\W" "-" (if (length> stripped-subject 50) > + (substring stripped-subject 0 50) > + stripped-subject)) Is limiting the file names to ~50 characters a Git thing? > + "-+" "-+") > + ".patch"))) Perhaps this should be pulled out into a separate function. > + (mml-attach-buffer > + (buffer-name (plist-get patch :buffer)) > + "text/x-patch" > + patch-subject > + "attachment" > + (format "%04d-%s" (cl-incf i) filename)))))) Is the new additional argument really necessary, or couldn't we just rename the generated buffer? We could specify that the buffer must be fresh/renameable. > (open-line 2))))) > > (defun vc-default-responsible-p (_backend _file)