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#58383: 29.0.50; Make it easier to invert vc-prepare-patches-separately Date: Sun, 13 Nov 2022 16:06:58 +0000 Message-ID: <87mt8uvnx9.fsf@posteo.net> References: <87mta6b3yu.fsf@melete.silentflame.com> <87edvh2m3o.fsf@posteo.net> <87v8nq4b62.fsf@melete.silentflame.com> <87cz9xgpd9.fsf@posteo.net> <87sfityxe8.fsf@melete.silentflame.com> <87sfisedkk.fsf@posteo.net> <87educytij.fsf@melete.silentflame.com> <87iljo9g1h.fsf@posteo.net> <875yfnzw14.fsf@melete.silentflame.com> <87v8nm5zzp.fsf@posteo.net> <87pmduwdzs.fsf@melete.silentflame.com> <87bkpexaqh.fsf@posteo.net> <87wn81us9q.fsf@melete.silentflame.com> <87a64vvtyh.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2455"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58383@debbugs.gnu.org To: Sean Whitton Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 13 17:08:15 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 1ouFWo-0000RL-PT for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Nov 2022 17:08:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouFWe-00057j-9B; Sun, 13 Nov 2022 11:08:04 -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 1ouFWc-00057L-60 for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2022 11:08: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 1ouFWb-0000dk-Tq for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2022 11:08:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ouFWb-00029E-Na for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2022 11:08: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: Sun, 13 Nov 2022 16:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58383 X-GNU-PR-Package: emacs Original-Received: via spool by 58383-submit@debbugs.gnu.org id=B58383.16683556368201 (code B ref 58383); Sun, 13 Nov 2022 16:08:01 +0000 Original-Received: (at 58383) by debbugs.gnu.org; 13 Nov 2022 16:07:16 +0000 Original-Received: from localhost ([127.0.0.1]:52383 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouFVr-00028C-Fr for submit@debbugs.gnu.org; Sun, 13 Nov 2022 11:07:15 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:54095) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouFVn-00027w-Dd for 58383@debbugs.gnu.org; Sun, 13 Nov 2022 11:07:13 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 7CBAD240027 for <58383@debbugs.gnu.org>; Sun, 13 Nov 2022 17:07:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1668355625; bh=W4KDOpd8lxyIb5cOsXNMzEccBR1tOQRELBSW0t9aNuY=; h=From:To:Cc:Subject:Date:From; b=FmChklsB2TPRD4Q8POpvKBiA35zZWUuY+/fhyIVqGTkS+RZG9KKqRziwcsD6aRFyp LbiI1QeDPBHQoA1Aq+8SxI8w9CYHVNuBk1H5F+BgIyJotar00CJb+uy5RdJcoYpFrs 7LTyic23t63KmKJ2IN0K64TKCdwqWDpOYJT3oNNdJ60Y0A/IuiFjE9Dl0QO5j/EfK3 zJSZ6WP9aoA+ZUYNTZJ+n2d/29xQFOreaEqZL1L3rcdSzi3re9/V0NkwDDdxm2aDCx dMFzZN/eIIcxe0i2avOZzhX1WXBG/iolf1PfLzspMOO1MbTiBOYia7WZcNidcrBnR0 9dGVMj1XPMFWw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N9HQ02hdTz9rxG; Sun, 13 Nov 2022 17:07:03 +0100 (CET) In-Reply-To: <87a64vvtyh.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 13 Nov 2022 14:56:38 +0100") 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:247788 Archived-At: --=-=-= Content-Type: text/plain Philip Kaludercic writes: > How does the following look like: I have prepared a proper patch: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Have-vc-prepare-patch-handle-prefix-arguments.patch >From 724b85acd34e4e5dd6e8cb521eb03eda08ff105a Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sun, 13 Nov 2022 17:05:20 +0100 Subject: [PATCH] Have 'vc-prepare-patch' handle prefix arguments. * lisp/emacs-lisp/package-vc.el (package-vc-prepare-patch): Use 'vc-prepare-patch-prompt-revisions'. * lisp/vc/vc.el (vc-prepare-patch-prompt-revisions): Extract common function and handle prefix arguments. (vc-prepare-patch): Pull logic out to 'vc-prepare-patch-prompt-revisions'. --- lisp/emacs-lisp/package-vc.el | 14 ++++++------ lisp/vc/vc.el | 40 +++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 664629d156..37ef35edad 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -733,17 +733,17 @@ package-vc-rebuild ;;;###autoload (defun package-vc-prepare-patch (pkg subject revisions) "Send patch for REVISIONS to maintainer of the package PKG using SUBJECT. -SUBJECT and REVISIONS are passed on to `vc-prepare-patch', which see. -PKG must be a package description. -Interactively, prompt for PKG, SUBJECT, and REVISIONS. However, -if the current buffer has marked commit log entries, REVISIONS -are the tags of the marked entries, see `log-view-get-marked'." +SUBJECT and REVISIONS are passed on to `vc-prepare-patch', which +see. PKG must be a package description. Interactively, prompt +for PKG, SUBJECT, and REVISIONS. When invoked with a numerical +prefix argument, the last N revisions will be used. When invoked +interactively in a Log View buffer with marked revisions, those +revisions will be used." (interactive (list (package-vc--read-package-desc "Package to prepare a patch for: " t) (and (not vc-prepare-patches-separately) (read-string "Subject: " "[PATCH] " nil nil t)) - (or (log-view-get-marked) - (vc-read-multiple-revisions "Revisions: ")))) + (vc-prepare-patch-prompt-revisions))) (vc-prepare-patch (package-maintainers pkg t) subject revisions)) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 513fbb23fe..f49f5d3307 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3384,6 +3384,30 @@ vc-default-prepare-patch (vc-root-dir)))) :buffer (current-buffer))))) +(defun vc-prepare-patch-prompt-revisions () + "Prompt the user for a list revisions. +Prepare a default value, depending on the current context. With +a numerical prefix argument, use the last N revisions as the +default value. If the current buffer is a log-view buffer, use +the marked commits. Otherwise fall back to the working revision +of the current file." + (vc-read-multiple-revisions + "Revisions: " nil nil nil + (or (and-let* ((arg current-prefix-arg) + (fs (vc-deduce-fileset t))) + (cl-loop with file = (caadr fs) + repeat (prefix-numeric-value arg) + for rev = (vc-working-revision file) + then (vc-call-backend + (car fs) 'previous-revision + file rev) + when rev collect it into revs + finally return (mapconcat #'identity revs ","))) + (and-let* ((revs (log-view-get-marked))) + (mapconcat #'identity revs ",")) + (and-let* ((file (buffer-file-name))) + (vc-working-revision file))))) + ;;;###autoload (defun vc-prepare-patch (addressee subject revisions) "Compose an Email sending patches for REVISIONS to ADDRESSEE. @@ -3391,18 +3415,12 @@ vc-prepare-patch as the default subject for the message (and it will be prompted for when called interactively). Otherwise a separate message will be composed for each revision, with SUBJECT derived from the -invidividual commits. - -When invoked interactively in a Log View buffer with marked -revisions, those revisions will be used." +invidividual commits. When invoked with a numerical prefix +argument, the last N revisions will be used. When invoked +interactively in a Log View buffer with marked revisions, those +revisions will be used." (interactive - (let ((revs (vc-read-multiple-revisions - "Revisions: " nil nil nil - (or (and-let* ((revs (log-view-get-marked))) - (mapconcat #'identity revs ",")) - (and-let* ((file (buffer-file-name))) - (vc-working-revision file))))) - to) + (let ((revs (vc-prepare-patch-prompt-revisions)) to) (require 'message) (while (null (setq to (completing-read-multiple (format-prompt -- 2.35.1 --=-=-=--