From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#57400: 29.0.50; Support sending patches from VC directly Date: Tue, 11 Oct 2022 08:37:26 +0300 Message-ID: <83pmeygbu1.fsf@gnu.org> References: <84v8qgn1z9.fsf@iki.fi> <87h71zo3p8.fsf@posteo.net> <87sfljmgwz.fsf@posteo.net> <87y1twvima.fsf@posteo.net> <84sfk2p846.fsf@iki.fi> <87h70i9ntt.fsf@posteo.net> <87edvl6vbj.fsf@gmail.com> <8735c1nn3y.fsf@posteo.net> <877d1d6rcy.fsf@gmail.com> <867d1cjc8w.fsf@mail.linkov.net> <87o7unkggk.fsf@posteo.net> <86edvids93.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19910"; mail-complaints-to="usenet@ciao.gmane.io" Cc: philipk@posteo.net, 57400@debbugs.gnu.org, rpluim@gmail.com, ane@iki.fi, juri@linkov.net To: rms@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 11 07:40:47 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 1oi80U-000510-NJ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Oct 2022 07:40:46 +0200 Original-Received: from localhost ([::1]:33174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oi80T-0007s4-5N for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Oct 2022 01:40:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi7xt-0007r7-Al for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 01:38:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oi7xq-0000cv-4y for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 01:38:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oi7xp-00058T-Rb for bug-gnu-emacs@gnu.org; Tue, 11 Oct 2022 01:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Oct 2022 05:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57400 X-GNU-PR-Package: emacs Original-Received: via spool by 57400-submit@debbugs.gnu.org id=B57400.166546665419705 (code B ref 57400); Tue, 11 Oct 2022 05:38:01 +0000 Original-Received: (at 57400) by debbugs.gnu.org; 11 Oct 2022 05:37:34 +0000 Original-Received: from localhost ([127.0.0.1]:50614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi7xN-00057l-Rv for submit@debbugs.gnu.org; Tue, 11 Oct 2022 01:37:34 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oi7xL-00057X-S5 for 57400@debbugs.gnu.org; Tue, 11 Oct 2022 01:37:32 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi7xF-0000aK-Qx; Tue, 11 Oct 2022 01:37:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=lNKLseL6yY7Wy8lOfKLMBmJYQRcDOuS5VoC/2WurcCk=; b=Xp9cBfLX9rYu WvQdMDDFGfutwHFRJXb64ttWNA2MUvQmwzHXh1RbzcMf6o7+20xO60tEdyo65rNjBW2u235mkO9sG oliylNJ03GgpM4lvNR+IooamfqvHmK9yI4qfSS+0ne7m8kJuJnnH2hTGojR4277S88WTRzlaNY38c Z9QqrAtl7pRJQs5mgfQdhctXIw9gSjoNQxwhp2PjCvxAtJQHabv8C7gCGkVQLJ1QWRj8nvRGazu8U 4FvocUVF+Xq3iAtXR+xi3CHNuxGKpUcQ6L1Eur043p27vbq5muNCrxQk1t/TRiqSxtUI3dXd09yDT 5dS26axYwdaN8Cw7fyZhRw==; Original-Received: from [87.69.77.57] (port=1287 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi7x7-0006AR-Jn; Tue, 11 Oct 2022 01:37:18 -0400 In-Reply-To: (message from Richard Stallman on Mon, 10 Oct 2022 18:01:21 -0400) 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" Xref: news.gmane.io gmane.emacs.bugs:245086 Archived-At: > Cc: philipk@posteo.net, 57400@debbugs.gnu.org, rpluim@gmail.com, ane@iki.fi > From: Richard Stallman > Date: Mon, 10 Oct 2022 18:01:21 -0400 > > Can someone please send me a self-contained description of this new > feature? It's in Git, including documentation which describes the feature. You can find the changeset by searching "git log" output for the bug number, 57400. I attach below the docs parts of the changeset and the command itself. > Which VC backends does it support? All of them, AFAIU. diff --git a/doc/emacs/vc1-xtra.texi b/doc/emacs/vc1-xtra.texi index 05d2144..66d3f51 100644 --- a/doc/emacs/vc1-xtra.texi +++ b/doc/emacs/vc1-xtra.texi @@ -16,6 +16,7 @@ Miscellaneous VC * Revision Tags:: Symbolic names for revisions. * Version Headers:: Inserting version control headers into working files. * Editing VC Commands:: Editing the VC shell commands that Emacs will run. +* Preparing Patches:: Preparing and Composing patches from within VC @end menu @node Change Logs and VC @@ -282,6 +283,32 @@ Editing VC Commands additional branches to the end of the @samp{git log} command that VC is about to run. +@node Preparing Patches +@subsubsection Preparing Patches + +@findex vc-prepare-patch +When collaborating on projects it is common to send patches via email, +to share changes. If you wish to do this using VC, you can use the +@code{vc-prepare-patch} command. This will prompt you for the +revisions you wish to share, and which destination email address(es) +to use. The command will then prepare those revisions using your +@abbr{MUA, Mail User Agent} for you to review and send. + +@vindex vc-prepare-patches-separately +Depending on the value of the user option +@code{vc-prepare-patches-separately}, @code{vc-prepare-patch} will +generate one or more messages. The default value @code{t} means +prepare and display a message for each revision, one after another. A +value of @code{nil} means to generate a single message with all +patches attached in the body. + +@vindex vc-default-patch-addressee +If you expect to contribute patches on a regular basis, you can set +the user option @code{vc-default-patch-addressee} to the address(es) +you wish to use. This will be used as the default value when invoking +@code{vc-prepare-patch}. Project maintainers may consider setting +this as a directory local variable (@pxref{Directory Variables}). + @node Customizing VC @subsection Customizing VC diff --git a/etc/NEWS b/etc/NEWS index f674423..ca85705 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1866,6 +1866,24 @@ Git commands display summary lines. See the two new user options It is used to style the line that separates the 'log-edit' headers from the 'log-edit' summary. +--- +*** The function 'vc-read-revision' accepts a new MULTIPLE argument. +If non-nil, multiple revisions can be queried. This is done using +'completing-read-multiple'. + +--- +*** New function 'vc-read-multiple-revisions' +This function invokes 'vc-read-revision' with a non-nil value for +MULTIPLE. + ++++ +*** New command 'vc-prepare-patch'. +Patches for any version control system can be prepared using VC. The +command will query what commits to send and will compose messages for +your mail user agent. The behaviour of 'vc-prepare-patch' can be +modified by the user options 'vc-prepare-patches-separately' and +'vc-default-patch-addressee'. + ** Message --- diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 787dd51..72189cf 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -574,6 +574,16 @@ ;; containing FILE-OR-DIR. The optional REMOTE-NAME specifies the ;; remote (in Git parlance) whose URL is to be returned. It has ;; only a meaning for distributed VCS and is ignored otherwise. +;; +;; - prepare-patch (rev) +;; +;; Prepare a patch and return a property list with the keys +;; `:subject' indicating the patch message as a string, `:buffer' +;; with a buffer object that contains the entire patch message and +;; `:body-start' and `:body-end' demarcating what part of said +;; buffer should be inserted into an inline patch. If the two last +;; properties are omitted, `point-min' and `point-max' will +;; respectively be used instead. +(defcustom vc-prepare-patches-separately t + "Non-nil means that `vc-prepare-patch' creates a single message. +A single message is created by attaching all patches to the body +of a single message. If nil, each patch will be sent out in a +separate message, which will be prepared sequentially." + :type 'boolean + :safe #'booleanp + :version "29.1") + +(defcustom vc-default-patch-addressee nil + "Default addressee for `vc-prepare-patch'. +If nil, no default will be used. This option may be set locally." + :type '(choice (const :tag "No default" nil) + (string :tag "Addressee")) + :safe #'stringp + :version "29.1") + +;;;###autoload +(defun vc-prepare-patch (addressee subject revisions) + "Compose an Email sending patches for REVISIONS to ADDRESSEE. +If `vc-prepare-patches-separately' is non-nil, SUBJECT will be used +as the default subject for the message. Otherwise a separate +message will be composed for each revision. + +When invoked interactively in a Log View buffer with marked +revisions, these revisions will be used." + (interactive + (let ((revs (or (log-view-get-marked) + (vc-read-multiple-revisions "Revisions: "))) + to) + (require 'message) + (while (null (setq to (completing-read-multiple + (format-prompt + "Addressee" + vc-default-patch-addressee) + (message--name-table "") + nil nil nil nil + vc-default-patch-addressee))) + (message "At least one addressee required.") + (sit-for blink-matching-delay)) + (list (string-join to ", ") + (and (not vc-prepare-patches-separately) + (read-string "Subject: " "[PATCH] " nil nil t)) + revs))) + (save-current-buffer + (vc-ensure-vc-buffer) + (let ((patches (mapcar (lambda (rev) + (vc-call-backend + (vc-responsible-backend default-directory) + 'prepare-patch rev)) + revisions))) + (if vc-prepare-patches-separately + (dolist (patch patches) + (compose-mail addressee + (plist-get patch :subject) + nil nil nil nil + `((kill-buffer ,(plist-get patch :buffer)) + (exit-recursive-edit))) + (rfc822-goto-eoh) (forward-line) + (save-excursion ;don't jump to the end + (insert-buffer-substring + (plist-get patch :buffer) + (plist-get patch :body-start) + (plist-get patch :body-end))) + (recursive-edit)) + (compose-mail addressee subject nil nil nil nil + (mapcar + (lambda (p) + (list #'kill-buffer (plist-get p :buffer))) + patches)) + (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"))) + (open-line 2))))) + (defun vc-default-responsible-p (_backend _file) "Indicate whether BACKEND is responsible for FILE. The default is to return nil always."