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.
This commit is contained in:
Sean Whitton 2025-10-04 14:41:16 +01:00
parent 2ce33b66c5
commit d0c63b8427
3 changed files with 13 additions and 13 deletions

View file

@ -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}),

View file

@ -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

View file

@ -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)