From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.bugs Subject: bug#57807: vc-edit-next-command (was bug#57807: 29.0.50; Make vc-print-branch-log able to log multiple branches) Date: Tue, 27 Sep 2022 18:15:01 -0700 Message-ID: <87k05ofgfe.fsf_-___14725.9349397913$1664328049$gmane$org@melete.silentflame.com> References: <87czbxub4b.fsf@melete.silentflame.com> <87fsgs396r.fsf@melete.silentflame.com> <8635cs8s59.fsf@mail.linkov.net> <87leqk1day.fsf@melete.silentflame.com> <86o7vfpzya.fsf@mail.linkov.net> <87sfkos6as.fsf@melete.silentflame.com> <86bkrb7qt8.fsf@mail.linkov.net> <8735clu05s.fsf@melete.silentflame.com> <864jx0o903.fsf@mail.linkov.net> <87o7v8ple4.fsf@melete.silentflame.com> <86illgc542.fsf@mail.linkov.net> <875yhfo0en.fsf@melete.silentflame.com> <86h70zp8br.fsf@mail.linkov.net> <87wn9vjecm.fsf@melete.silentflame.com> <86y1uad298.fsf@mail.linkov.net> <87fsggd1f1.fsf@melete.silentflame.com> <86v8pc5yff.fsf@mail.linkov.net> <87r100bbto.fsf@melete.silentflame.com> <86o7v3kj30.fsf@mail.linkov.net> <87r0zxlqa5.fsf@melete.silentflame.com> <861qrwocbb.fsf@mail.linkov.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="7986"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 57807@debbugs.gnu.org To: Juri Linkov , emacs-devel@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 28 03:20:41 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 1odLke-0001sl-ML for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Sep 2022 03:20:41 +0200 Original-Received: from localhost ([::1]:60846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odLkd-0005AU-GV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Sep 2022 21:20:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odLgA-0001jy-7n for bug-gnu-emacs@gnu.org; Tue, 27 Sep 2022 21:16:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odLg9-0003Wg-W8 for bug-gnu-emacs@gnu.org; Tue, 27 Sep 2022 21:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1odLg9-0006yL-MG for bug-gnu-emacs@gnu.org; Tue, 27 Sep 2022 21:16:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Sep 2022 01:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57807 X-GNU-PR-Package: emacs Original-Received: via spool by 57807-submit@debbugs.gnu.org id=B57807.166432771226739 (code B ref 57807); Wed, 28 Sep 2022 01:16:01 +0000 Original-Received: (at 57807) by debbugs.gnu.org; 28 Sep 2022 01:15:12 +0000 Original-Received: from localhost ([127.0.0.1]:57057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odLfL-0006xC-8b for submit@debbugs.gnu.org; Tue, 27 Sep 2022 21:15:11 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33349) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odLfJ-0006ww-1J for 57807@debbugs.gnu.org; Tue, 27 Sep 2022 21:15:09 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0246D5C0148; Tue, 27 Sep 2022 21:15:03 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 27 Sep 2022 21:15:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1664327702; x=1664414102; bh=M2 JXL1NqYAxHWd0/exwAZHgUkmdz5Jo9oaqwLZa9r70=; b=xESDja2vfAxTf1Et2+ Ix6oyrXUk3YGaTgIlr/TioN+mXkNbKlGsTlSC1BGr/47xlC2XOQ/TrDNvGbsbF1n Qjdh5/W9TW7pHFPdRjQv+tUkbTXCzhGfpeDAExK0LtNeyDfGoNiQv0amJ6N7Lwl6 dzJKZCgav7EEoRUrbPrKkTWoLeOxvFK2Jnd9e8rKham/RBhrYxwei3S39w5ROkX6 49wMAebQXPwhTwY9oOvDD3LA4U81mKVUDUGn1NknKgm0geoFBsvKHaGuVUMDqeZL uyvTg8QwAXBSfSTXl+RESECUUHzbqWcxw16XtyllGkaRI0MtlN/GpyIeweAkNcNh jBTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1664327702; x=1664414102; bh=M2JXL1NqYAxHWd0/exwAZHgUkmdz 5Jo9oaqwLZa9r70=; b=dy8OPPbv/ZzyeJLoqOd6WgLIZDqHbEqJwhoQ/w18iMnn PEZSXiwD2SBjgGeS3FND8nPasKI67Rxy2f7rjb9mSqemeY1+laZshL6h0vYCqaRz TJEOFJHupXCz1k3SEL/cTwDispWDpOBZym/gMUGzRVtFNEhD5PPSeDy4IZMvJbPV Sy7hS20yH2a9QmHxvS7XVnbXPGe4kLmLAo2jvbzPfebGNsjQAbdZTLtu89s+8D0U 0H0LoxbQLKuGe3gWPynsj7k/0rvE7zTSV93wxUyOOB5UHJ812oYGoX8eu8oDpHTd DuM63PX+zYi/4pWC43meikm0sIkvGfoM+yQtzpTMxQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeegjedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffffkfgggtgesmhdttdertdertdenucfhrhhomhepufgvrghn ucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpeffveeuhfeludfhfeegjeefhefhfeeludejueehfeevtdfh hfettedtfeelleetudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg X-ME-Proxy: Feedback-ID: i23c04076:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 Sep 2022 21:15:02 -0400 (EDT) Original-Received: by melete.silentflame.com (Postfix, from userid 1000) id 083DC7E14CC; Tue, 27 Sep 2022 18:15:02 -0700 (MST) In-Reply-To: <861qrwocbb.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 27 Sep 2022 21:59:04 +0300") 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:243774 Archived-At: --=-=-= Content-Type: text/plain Hello, On Tue 27 Sep 2022 at 09:59PM +03, Juri Linkov wrote: >>> Thanks, I'm going to try it out. >> >> It looks like I need to call (minibuffer-depth) like >> display-buffer-override-next-command does. Updated patch attached. > > I tested your latest patch with many vc commands, and everything > works nicely, even M-x for vc commands without a keybinding > and with a prefix arg is supported like in > > C-x v ! C-u M-x vc-log-search RET > > (C-u is not needed for vc-log-search anymore, > it's just for testing a prefix arg here). Thank you for the through testing. Here is a more formal patch, including manual updates. >> I realised that we could add an override inside vc-read-revision, and >> potentially other places, which makes it considerably less annoying. >> Done in the attached. > > Maybe it's fine to disable editing for vc-read-revision, > but I'm not sure about other commands, such as e.g. > vc-git-log-incoming that runs two git commands: > > vc-git-command fetch > vc-git-command log > > I see no problem to type an extra RET even for a secondary git command. > But it helps in case when someone really wants to edit it. Yeah, we should be conservative. I've done it for only vc-read-revision for now, and perhaps I'll raise some others later. -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v3-0001-Add-vc-edit-next-command.patch >From 381c04afb4f741fbbf2f4dfcda3973c3738d0442 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 24 Sep 2022 16:17:56 -0700 Subject: [PATCH v3] Add vc-edit-next-command * lisp/vc/vc.el (vc-read-revision): Override vc-filter-command-function back to its default value. (vc-print-branch-log): Remove recently-added prefix argument. (vc-edit-next-command): New command. * lisp/vc/vc-hooks.el (vc-prefix-map): Bind it to 'C-x v !'. * etc/NEWS: * doc/emacs/vc1-xtra.texi (Editing Shell Commands): Document it. --- doc/emacs/vc1-xtra.texi | 26 ++++++++++++++++---- etc/NEWS | 7 ++++++ lisp/vc/vc-hooks.el | 3 ++- lisp/vc/vc.el | 53 ++++++++++++++++++++++++++++------------- 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/doc/emacs/vc1-xtra.texi b/doc/emacs/vc1-xtra.texi index 3ccad50715..1266873c4b 100644 --- a/doc/emacs/vc1-xtra.texi +++ b/doc/emacs/vc1-xtra.texi @@ -11,10 +11,11 @@ Miscellaneous VC This section explains the less-frequently-used features of VC. @menu -* Change Logs and VC:: Generating a change log file from log entries. -* VC Delete/Rename:: Deleting and renaming version-controlled files. -* Revision Tags:: Symbolic names for revisions. -* Version Headers:: Inserting version control headers into working files. +* Change Logs and VC:: Generating a change log file from log entries. +* VC Delete/Rename:: Deleting and renaming version-controlled files. +* Revision Tags:: Symbolic names for revisions. +* Version Headers:: Inserting version control headers into working files. +* Editing Shell Commands:: Editing the VC shell commands that Emacs will run. @end menu @node Change Logs and VC @@ -263,6 +264,23 @@ Version Headers part of the version header. A @samp{%s} in @var{format} is replaced with the file's version control type. +@node Editing Shell Commands +@subsubsection Editing Shell Commands + +@findex vc-edit-next-command +@kindex C-x v ! +You can use the @kbd{C-x v !} (@code{vc-edit-next-command}) prefix +command to request an opportunity to edit the VC shell commands that +Emacs will run. This is primarily intended to make it possible to +access version control system-specific functionality without +complexifying either the VC command set or the backend API. + +For example, Git can produce logs of more than one branch, but +@kbd{C-x v b l} (@code{vc-print-branch-log}) prompts for the name of +just one branch. To obtain a log of more than one branch, you can +type @kbd{C-x v ! C-x v b l} and then append the names of additional +branches to the end of the 'git log' command that VC prepares. + @node Customizing VC @subsection Customizing VC diff --git a/etc/NEWS b/etc/NEWS index 5b15e9dcb6..d1d3fc6f89 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1722,6 +1722,13 @@ commands. This command marks files based on a regexp. If given a prefix argument, unmark instead. ++++ +*** New command 'C-x v !' ('vc-edit-next-command') +This prefix command requests editing of the next VC shell command +before execution. For example, in a Git repository, you can produce a +log of more than one branch by typing 'C-x v ! C-x v b l' and then +appending additional branch names to the 'git log' command. + --- *** 'C-x v v' in a diffs buffer allows to commit only some of the changes. This command is intended to allow you to commit only some of the diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 7f0d9e4d86..6ad26cfe67 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -882,7 +882,8 @@ vc-prefix-map "=" #'vc-diff "D" #'vc-root-diff "~" #'vc-revision-other-window - "x" #'vc-delete-file) + "x" #'vc-delete-file + "!" #'vc-edit-next-command) (fset 'vc-prefix-map vc-prefix-map) (define-key ctl-x-map "v" 'vc-prefix-map) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 4950a1a32d..e18fd6f5c8 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1918,8 +1918,11 @@ vc-read-revision (setq files (cadr vc-fileset)) (setq backend (car vc-fileset)))) ((null backend) (setq backend (vc-backend (car files))))) - (let ((completion-table - (vc-call-backend backend 'revision-completion-table files))) + ;; Override any `vc-filter-command-function' value, as user probably + ;; doesn't want to edit the command to get the completions. + (let* ((vc-filter-command-function #'list) + (completion-table + (vc-call-backend backend 'revision-completion-table files))) (if completion-table (completing-read prompt completion-table nil nil initial-input 'vc-revision-history default) @@ -2745,28 +2748,17 @@ vc-print-root-log (setq vc-parent-buffer-name nil))) ;;;###autoload -(defun vc-print-branch-log (branch &optional arg) - "Show the change log for BRANCH root in a window. -Optional prefix ARG non-nil requests an opportunity for the user -to edit the VC shell command that will be run to generate the -log." - ;; The original motivation for ARG was to make it possible to - ;; produce a log of more than one Git branch without modifying the - ;; print-log VC API. The user can append the other branches to the - ;; command line arguments to 'git log'. See bug#57807. +(defun vc-print-branch-log (branch) + "Show the change log for BRANCH root in a window." (interactive (let* ((backend (vc-responsible-backend default-directory)) (rootdir (vc-call-backend backend 'root default-directory))) (list - (vc-read-revision "Branch to log: " (list rootdir) backend) - current-prefix-arg))) + (vc-read-revision "Branch to log: " (list rootdir) backend)))) (when (equal branch "") (error "No branch specified")) (let* ((backend (vc-responsible-backend default-directory)) - (rootdir (vc-call-backend backend 'root default-directory)) - (vc-filter-command-function (if arg - #'vc-user-edit-command - vc-filter-command-function))) + (rootdir (vc-call-backend backend 'root default-directory))) (vc-print-log-internal backend (list rootdir) branch t (when (> vc-log-show-limit 0) vc-log-show-limit)))) @@ -3244,6 +3236,33 @@ vc-update-change-log (vc-call-backend (vc-responsible-backend default-directory) 'update-changelog args)) +(defvar vc-filter-command-function) + +;;;###autoload +(defun vc-edit-next-command () + "Request editing the next VC shell command before execution. +This is a prefix command. It affects only a VC command executed +immediately after this one." + (interactive) + (letrec ((minibuffer-depth (minibuffer-depth)) + (command this-command) + (keys (key-description (this-command-keys))) + (old vc-filter-command-function) + (echofun (lambda () keys)) + (postfun + (lambda () + (unless (or (eq this-command command) + (> (minibuffer-depth) minibuffer-depth)) + (remove-hook 'post-command-hook postfun) + (remove-hook 'prefix-command-echo-keystrokes-functions + echofun) + (setq vc-filter-command-function old))))) + (add-hook 'post-command-hook postfun) + (add-hook 'prefix-command-echo-keystrokes-functions echofun) + (setq vc-filter-command-function + (lambda (&rest args) + (apply #'vc-user-edit-command (apply old args)))))) + (defun vc-default-responsible-p (_backend _file) "Indicate whether BACKEND is responsible for FILE. The default is to return nil always." -- 2.30.2 --=-=-=--