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:45:26 +0000 Message-ID: <87fsemvm55.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> <83bkpalsme.fsf@gnu.org> 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="337"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58383@debbugs.gnu.org, spwhitton@spwhitton.name To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 13 17:46:32 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 1ouG7r-000AOd-Kz for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Nov 2022 17:46:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouG7f-0005j6-Ri; Sun, 13 Nov 2022 11:46:19 -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 1ouG7P-0005gM-Bz for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2022 11:46:04 -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 1ouG7P-0007zm-47 for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2022 11:46:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ouG7O-00035Z-Mf for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2022 11:46:02 -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:46:02 +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.166835793711828 (code B ref 58383); Sun, 13 Nov 2022 16:46:02 +0000 Original-Received: (at 58383) by debbugs.gnu.org; 13 Nov 2022 16:45:37 +0000 Original-Received: from localhost ([127.0.0.1]:52419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouG6y-00034h-FA for submit@debbugs.gnu.org; Sun, 13 Nov 2022 11:45:36 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:50833) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouG6v-00034U-Qm for 58383@debbugs.gnu.org; Sun, 13 Nov 2022 11:45:35 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 56343240105 for <58383@debbugs.gnu.org>; Sun, 13 Nov 2022 17:45:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1668357928; bh=gEcL9C6188RGUdetXsgPTxjxRPnIOR3Si0kg2oDR7Ek=; h=From:To:Cc:Subject:Date:From; b=k/upJK4CMD06WqvE3OzsFuzv5qHy8gp9OZs3uB2DbOLq+VAY+6mgp/WnWTAXjbLLO qrcjZaY//YJHX2vGxRJxkfUMpB3ZTMwDPiYkVOLxIrQnlafsVdceI5p8qJM8/jqpN8 mEBVkKzfeo7OVSRueZr2Ery3LllSmEj9IPV82C13Tq745Bd9y5cFLJC2rqV2Pz90nJ xq0Pw1/9VdKfeNQYrQeTTUrpuxQojPSLVrkN1oDA5+fZR+BtUNuAORMMYn8oOEJvOo jTyJ4US8pSTR9Ji7eEUuksuaAGEOQKd0xN4bjHhoYh+7D9rCk9bn5EcSc5U65Ml/dG LcZKDfX6hOwSA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N9JGG4Qf9z6tmJ; Sun, 13 Nov 2022 17:45:26 +0100 (CET) In-Reply-To: <83bkpalsme.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 13 Nov 2022 18:35:37 +0200") 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:247793 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Can we take this opportunity to get rid of the passive voice and > clarify the doc string, please? Done: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Have-vc-prepare-patch-handle-prefix-arguments.patch >From 454c8c6ebb69c3cd3f671f7700ded14826492ce1 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 | 47 ++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 22 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..f71783db97 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3384,25 +3384,42 @@ 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. -If `vc-prepare-patches-separately' is nil, SUBJECT will be used -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." +If `vc-prepare-patches-separately' is nil, use SUBJECT as the +default subject for the message, or prompt a subject when invoked +interactively. Otherwise compose a separate message for each +revision, with SUBJECT derived from each revision subject. When +invoked with a numerical prefix argument, use the last N +revisions. When invoked interactively in a Log View buffer with +marked revisions, use those these." (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 --=-=-=--