From fbbce9d405be21ab2982913d827d5de47255d07c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 29 Dec 2025 15:12:41 +0000 Subject: [PATCH] New commands vc-print-change-log & vc-print-root-change-log * lisp/vc/vc.el (vc--read-branch-to-log): Call vc-deduce-fileset. Don't wrap return value in a list. (vc-print-fileset-branch-log, vc-print-root-branch-log): Adjust calls to vc--read-branch-to-log. (vc-print-change-log, vc-print-root-change-log): New commands (bug#80037). * etc/NEWS: Announce them. --- etc/NEWS | 13 +++++++++++ lisp/vc/vc.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 56a9f44ff31..0743d56a20b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2716,6 +2716,19 @@ View mode, copies to the kill ring the ID of the revision at point in the log entry. If there are marked revisions, it copies the IDs of those, instead. +--- +*** New commands 'vc-print-change-log' and 'vc-print-root-change-log'. +These are just like 'vc-print-log' and 'vc-print-root-log' except that +they have a different prefix argument that some users may prefer. +With a prefix argument, these commands prompt for a branch, tag or other +reference to a revision to log, and a maximum number of revisions to +print. If you find this prefix argument more useful, or more mnemonic, +than the prefix arguments that 'vc-print-log' and 'vc-print-root-log' +already have, consider replacing the default global bindings, like this: + + (keymap-global-set "C-x v l" #'vc-print-change-log) + (keymap-global-set "C-x v L" #'vc-print-root-change-log) + --- *** New command alias 'vc-restore' for 'vc-revert'. diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 9645e8818c5..64538da9880 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3969,6 +3969,29 @@ shown log style is available via `vc-log-short-style'." (vc-print-log-internal (car fileset) (cadr fileset) working-revision nil limit))) +;;;###autoload +(defun vc-print-change-log () + "Show in another window the VC change history of the current fileset. +With a \\[universal-argument] prefix argument, prompt for a branch \ +or revision to log +instead of the working revision, and a number specifying the maximum +number of revisions to show; the default is `vc-log-show-limit'. +You can also use a numeric prefix argument to specify this. + +This is like `vc-print-log' but with an alternative prefix argument that +some users might prefer for interactive usage." + (declare (interactive-only vc-print-log)) + (interactive) + (if current-prefix-arg + (let ((branch + (vc--read-branch-to-log t)) + (vc-log-show-limit + (if (equal current-prefix-arg '(4)) + (vc--read-limit) + (prefix-numeric-value current-prefix-arg)))) + (vc-print-fileset-branch-log branch)) + (vc-print-log))) + ;;;###autoload (defun vc-print-root-log (&optional limit revision) "Show in another window VC change history of the current VC controlled tree. @@ -4002,13 +4025,39 @@ with its diffs (if the underlying VCS backend supports that)." ;; the mode line isn't helpful. (setq vc-parent-buffer-name nil)))) -(defun vc--read-branch-to-log (&optional files) +;;;###autoload +(defun vc-print-root-change-log () + "Show in another window the VC change history of the whole tree. +With a \\[universal-argument] prefix argument, prompt for a branch \ +or revision to log +instead of the working revision, and a number specifying the maximum +number of revisions to show; the default is `vc-log-show-limit'. +You can also use a numeric prefix argument to specify this. + +This is like `vc-root-print-log' but with an alternative prefix argument +that some users might prefer for interactive usage." + (declare (interactive-only vc-print-root-log)) + (interactive) + (if current-prefix-arg + (let ((branch + (vc--read-branch-to-log t)) + (vc-log-show-limit + (if (equal current-prefix-arg '(4)) + (vc--read-limit) + (prefix-numeric-value current-prefix-arg)))) + (vc-print-root-branch-log branch)) + (vc-print-root-log))) + +(defun vc--read-branch-to-log (&optional fileset) "Read the name of a branch to log. -FILES, if supplied, should be a list of file names." - (let ((branch (vc-read-revision "Branch to log: " files))) +FILESET, if non-nil, means to pass the current VC fileset to +`vc-read-revision'." + (let ((branch (vc-read-revision "Branch to log: " + (and fileset + (cadr (vc-deduce-fileset t)))))) (when (string-empty-p branch) (user-error "No branch specified")) - (list branch))) + branch)) ;;;###autoload (defun vc-print-fileset-branch-log (branch) @@ -4021,7 +4070,7 @@ starting at that revision. Tags and remote references also work." ;; used to prompt for a LIMIT argument like \\`C-x v l' has. Though ;; now we have "Show 2X entries" and "Show unlimited entries" that ;; might be a waste of the prefix argument to this command. --spwhitton - (interactive (vc--read-branch-to-log (cadr (vc-deduce-fileset t)))) + (interactive (list (vc--read-branch-to-log t))) (let ((fileset (vc-deduce-fileset t))) (vc-print-log-internal (car fileset) (cadr fileset) branch t (and (plusp vc-log-show-limit) @@ -4035,7 +4084,7 @@ In addition to logging branches, for VCS for which it makes sense you can specify a revision ID instead of a branch name to produce a log starting at that revision. Tags and remote references also work." ;; Prefix argument conserved; see previous command. --spwhitton - (interactive (vc--read-branch-to-log)) + (interactive (list (vc--read-branch-to-log))) (vc--with-backend-in-rootdir "VC branch log" (vc-print-log-internal backend (list rootdir) branch t (and (plusp vc-log-show-limit)