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: 29.0.50; Make vc-print-branch-log able to log multiple branches Date: Sun, 18 Sep 2022 14:48:11 -0700 Message-ID: <87sfkos6as.fsf@melete.silentflame.com> References: <87czbxub4b.fsf@melete.silentflame.com> <86v8ppn5b2.fsf@mail.linkov.net> <87h719shi6.fsf@melete.silentflame.com> <861qsdktqo.fsf@mail.linkov.net> <87fsgs396r.fsf@melete.silentflame.com> <8635cs8s59.fsf@mail.linkov.net> <87leqk1day.fsf@melete.silentflame.com> <86o7vfpzya.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="25253"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: Juri Linkov , 57807@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 18 23:49: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 1oa2A6-0006NO-8m for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 23:49:15 +0200 Original-Received: from localhost ([::1]:56798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oa2A5-0003Y5-BU for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 17:49:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oa29u-0003Vl-P6 for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 17:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oa29u-0008H6-Gf for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 17:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oa29u-00059E-3G for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 17:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Sep 2022 21:49:02 +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.166353770519742 (code B ref 57807); Sun, 18 Sep 2022 21:49:02 +0000 Original-Received: (at 57807) by debbugs.gnu.org; 18 Sep 2022 21:48:25 +0000 Original-Received: from localhost ([127.0.0.1]:51443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oa29I-00058M-IC for submit@debbugs.gnu.org; Sun, 18 Sep 2022 17:48:25 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:53463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oa29C-000581-MH for 57807@debbugs.gnu.org; Sun, 18 Sep 2022 17:48:22 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4B73D5C01DD; Sun, 18 Sep 2022 17:48:13 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 18 Sep 2022 17:48:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=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=1663537693; x=1663624093; bh=Nvps1yzig+ T5oeIUAZz6AUsR4rzJX33uf1pRXQyMQnk=; b=S4HApyYjbVeQTq80w+q85inqfB QbFxkxpdjiagskAZFeAtp6DLDN67wbB4sQvPeJPm7U1Wl1Y3g2QSrpXqKsnPuw5t tO/iCc64DZDvr0wlkXlw7ghcAhp731gZEn1iaAWFNzo2rtDFBvpRM8iTupzcrIuR 2vax0UB/MtfdDePduNZEqkccuKt26Ig0ceUFP7tN4XsBsLnYU/63uWA0YLiU3Dhw 4L3wF38GyWel4IASRkD56ha2lhQrIZpuU4DcEnLVSB5NZ6Fr2m8slnwJGA3nz5ug VZ4M5xFDTVElJ7Mxub6PLxU+WFLtK8T265J0A2xjIG7WiAuM2prFuv0W0Uig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1663537693; x=1663624093; bh=Nvps1yzig+T5oeIUAZz6AUsR4rzJ X33uf1pRXQyMQnk=; b=Tg8nrOQFLQj4cW7/9BMi+0Zuwx/VIDuiMMadPhtUXBm/ WNY71W9RAg0/ZZQjEYMRuwMzRMSe9PBv//+1uiQHgp245fcuI/UhrK4JGn74S1gQ Ti98zNA4E/CXBuj+H8U3Dh/zau4u2khEo3mh6/xUi289+2lAIFnsYphsCkf47PIn 57ucJl4HGbq1FeR+cYzd8gmaT7FWeib1ds5B7wxZuBJtbLx5u9H4qODTh+MjUN4q EOQFlrfm6adM/HcrWBcST9l+mCfXD8iHu9w1Tc/rAUrczreGZFGQO0mjyGMQRK3U p3b5xxP9c3P174vPWyiq7BhOL1wfINDiuH9/WyiinQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedviedgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufgjfhffkfgfgggtsehmtddtredtredtnecuhfhrohhmpefuvggrnhcu hghhihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqne cuggftrfgrthhtvghrnhepkeevleffheetleehteeludetjeehfeehgfetteeftddtjeej jedvveevgfeghfehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i23c04076:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 18 Sep 2022 17:48:12 -0400 (EDT) Original-Received: by melete.silentflame.com (Postfix, from userid 1000) id 8EE107F2357; Sun, 18 Sep 2022 14:48:11 -0700 (MST) In-Reply-To: <86o7vfpzya.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 16 Sep 2022 09:59:09 +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:243020 Archived-At: --=-=-= Content-Type: text/plain Hello, On Fri 16 Sep 2022 at 09:59AM +03, Juri Linkov wrote: > Yes, please try to prepare a patch, preferably without changing the > established backend API, maybe by using a global variable that later > could be reused to confirm and edit other commands. Here's my attempt. Let me know what you think. -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-support-for-user-edits-to-VC-command-arguments.patch >From db5cbe0a693d4f231141576b07ba68e3287ca645 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 18 Sep 2022 14:47:23 -0700 Subject: [PATCH] Add support for user edits to VC command arguments * lisp/vc/vc-dispatcher.el (vc-want-edit-command-p): New variable. (vc-do-command): If vc-want-edit-command-p is non-nil, prompt the user to edit the arguments to the VC command before execution. * lisp/vc/vc-git.el (vc-git--pushpull): Drop prompting code. Bind vc-want-edit-command-p so that vc-do-command handles the prompting. * lisp/vc/vc.el (vc-print-branch-log): A non-nil prefix argument now means vc-want-edit-command-p is bound to a non-nil value (bug#57807). --- lisp/vc/vc-dispatcher.el | 35 +++++++++++++++++++++++++++++------ lisp/vc/vc-git.el | 25 +++++++------------------ lisp/vc/vc.el | 14 ++++++++++---- 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 88bf6627ae..d83db53dc8 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -156,6 +156,9 @@ vc-parent-buffer (defvar vc-parent-buffer-name nil) (put 'vc-parent-buffer-name 'permanent-local t) +(defvar vc-want-edit-command-p nil + "If non-nil, let user edit the VC shell command before running it.") + ;; Common command execution logic (defun vc-process-filter (p s) @@ -296,15 +299,16 @@ vc-do-command files or be nil (to execute commands that don't expect a file name or set of files). If an optional list of FLAGS is present, that is inserted into the command line before the filename. + +If `vc-want-edit-command-p' is non-nil, prompt the user to edit +FLAGS before execution. + Return the return value of the slave command in the synchronous case, and the process object in the asynchronous case." - (when vc-tor - (push command flags) - (setq command "torsocks")) - ;; FIXME: file-relative-name can return a bogus result because - ;; it doesn't look at the actual file-system to see if symlinks - ;; come into play. (let* ((files + ;; FIXME: file-relative-name can return a bogus result + ;; because it doesn't look at the actual file-system to see + ;; if symlinks come into play. (mapcar (lambda (f) (file-relative-name (expand-file-name f))) (if (listp file-or-list) file-or-list (list file-or-list)))) ;; Keep entire commands in *Messages* but avoid resizing the @@ -312,6 +316,22 @@ vc-do-command ;; a such way that the important parts are at the beginning, ;; due to potential truncation of long messages. (message-truncate-lines t) + (files-separator-p (string= "--" (car (last flags)))) + (flags (if vc-want-edit-command-p + (append + (split-string-and-unquote + (read-shell-command + (format "Edit VC command arguments%s: %s " + (if files + " (files list to be appended)" + "") + command) + (combine-and-quote-strings + (remq nil (if files-separator-p + (butlast flags) + flags))))) + (and files-separator-p (list "--"))) + flags)) (full-command (concat (if (string= (substring command -1) "\n") (substring command 0 -1) @@ -321,6 +341,9 @@ vc-do-command (vc-inhibit-message (or (eq vc-command-messages 'log) (eq (selected-window) (active-minibuffer-window))))) + (when vc-tor + (push command flags) + (setq command "torsocks")) (save-current-buffer (unless (or (eq buffer t) (and (stringp buffer) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index a5d12f03bc..91951d3277 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1089,35 +1089,24 @@ vc-git-error-regexp-alist (declare-function vc-compilation-mode "vc-dispatcher" (backend)) (defvar compilation-directory) (defvar compilation-arguments) +(defvar vc-want-edit-command-p) (defun vc-git--pushpull (command prompt extra-args) "Run COMMAND (a string; either push or pull) on the current Git branch. If PROMPT is non-nil, prompt for the Git command to run." (let* ((root (vc-git-root default-directory)) (buffer (format "*vc-git : %s*" (expand-file-name root))) - (git-program vc-git-program) - args) - ;; If necessary, prompt for the exact command. - ;; TODO if pushing, prompt if no default push location - cf bzr. - (when prompt - (setq args (split-string - (read-shell-command - (format "Git %s command: " command) - (format "%s %s" git-program command) - 'vc-git-history) - " " t)) - (setq git-program (car args) - command (cadr args) - args (cddr args))) - (setq args (nconc args extra-args)) + ;; TODO if pushing, prompt if no default push location - cf bzr. + (vc-want-edit-command-p prompt)) (require 'vc-dispatcher) - (apply #'vc-do-async-command buffer root git-program command args) + (apply #'vc-do-async-command + buffer root vc-git-program command extra-args) (with-current-buffer buffer (vc-run-delayed (vc-compilation-mode 'git) (setq-local compile-command - (concat git-program " " command " " - (mapconcat #'identity args " "))) + (concat vc-git-program " " command " " + (mapconcat #'identity extra-args " "))) (setq-local compilation-directory root) ;; Either set `compilation-buffer-name-function' locally to nil ;; or use `compilation-arguments' to set `name-function'. diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index c67dad69fc..027dfc72ea 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1046,6 +1046,7 @@ log-view-vc-backend (defvar log-edit-vc-backend) (defvar diff-vc-backend) (defvar diff-vc-revisions) +(defvar vc-want-edit-command-p) (defun vc-deduce-backend () (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend) @@ -2744,17 +2745,22 @@ vc-print-root-log (setq vc-parent-buffer-name nil))) ;;;###autoload -(defun vc-print-branch-log (branch) - "Show the change log for BRANCH root in a window." +(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." (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)))) + (vc-read-revision "Branch to log: " (list rootdir) backend) + current-prefix-arg))) (when (equal branch "") (error "No branch specified")) (let* ((backend (vc-responsible-backend default-directory)) - (rootdir (vc-call-backend backend 'root default-directory))) + (rootdir (vc-call-backend backend 'root default-directory)) + (vc-want-edit-command-p arg)) (vc-print-log-internal backend (list rootdir) branch t (when (> vc-log-show-limit 0) vc-log-show-limit)))) -- 2.30.2 --=-=-=--