From d0c63b84276fd17ec330bec44cf82876ab48e489 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 4 Oct 2025 14:41:16 +0100 Subject: [PATCH] Improve log-view-copy-revision-as-kill * lisp/vc/log-view.el (log-view-copy-revision-as-kill): Signal user-error if there is no revision at point. * doc/emacs/maintaining.texi (VC Change Log): * etc/NEWS: Shorten docs for the new command. --- doc/emacs/maintaining.texi | 6 +++--- etc/NEWS | 10 ++++------ lisp/vc/log-view.el | 10 ++++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 5af0c0f938a..2f8a15a0b0b 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -1245,9 +1245,9 @@ earlier revision (@code{log-view-diff-changeset}). This shows the changes to all files made in that revision. @item w -Copy the revision of the marked log entries into the kill ring, as if -you had killed them with @kbd{M-w}. Multiple entries will be separated -by a space. +Copy the revision of the log entry at point, or all marked revisions, to +the kill ring, as if you had used @kbd{M-w} +(@code{log-view-copy-revision-as-kill}). @item @key{RET} In a compact-style log buffer (e.g., the one created by @kbd{C-x v L}), diff --git a/etc/NEWS b/etc/NEWS index cc6580e79bb..96d85ea6b0d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2393,12 +2393,10 @@ You can get back the old behavior with something like this: In addition, a new command 'U' removes all marks. ---- -*** A new command 'log-view-copy-revision-as-kill' added. -The new 'log-view-copy-revision-as-kill' command copies the revision of -the log entry at point to the kill-ring. When multiple log entries are -marked the command copies all revisions in a single space separated -string. The command is bound by default to `w' in log-view-mode-map. ++++ +*** New command 'w' in Log View mode. +'w' now copies the revision of the log entry at point to the kill ring. +If there are marked revisions, it copies those, instead. ** Diff mode diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el index 06c241161a9..ca84f4b7452 100644 --- a/lisp/vc/log-view.el +++ b/lisp/vc/log-view.el @@ -751,16 +751,18 @@ considered file(s)." fr to))) (defun log-view-copy-revision-as-kill () - "Copy the revision under point, as a string, to the `kill-ring'." + "Copy the revision at point to the kill ring. +If there are marked revisions, use those, separated by spaces." (interactive) (let ((revisions (log-view-get-marked))) (if (length> revisions 1) (let ((found (string-join revisions " "))) (kill-new found) (message "%s" found)) - (when-let* ((rev (or (car revisions) (cadr (log-view-current-entry))))) - (kill-new rev) - (message "%s" rev))))) + (if-let* ((rev (or (car revisions) (log-view-current-tag)))) + (progn (kill-new rev) + (message "%s" rev)) + (user-error "No revision at point"))))) (provide 'log-view)