Subject: Re: bug#78890: 31.0.50; Messy vc-annotate buffer names

From: Jim Porter <[email-masked]>
Date: Tue, 24 Jun 2025 23:02:31 -0700

On 6/24/2025 4:50 AM, Stephen Berman via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> On Tue, 24 Jun 2025 06:41:41 -0400 Kristoffer Balintona <[email-masked]> wrote:
> 
>> Would it be possible to have buffer names more like the following
>> instead upon calls to vc-annotate-next-revision and
>> vc-annotate-prev-revision?
>> 1. *Annotate vtable.el (rev f1737342518)*
>> 2. *Annotate vtable.el (rev fdab542a56201b1581abdc0df940e0c50abde1c7)*
>> 3. *Annotate vtable.el (rev 35e1ab970c1cfc6a1b62fbb920e0d2bb031765da)*
> 
> Does the attached patch give the results you want?

Here's another possible patch for this. It uses 'vc-parent-buffer', 
which might be nil when first annotating a file, but that works out 
nicely, since '(buffer-name nil)' gets the buffer name of the current 
buffer (i.e. the original source file). I think this should be safe, 
though I'm not an expert on the VC internals.

I also notice that the previous revisions use the full Git SHA, even 
though they *should* be abbreviated. That's a separate issue though, so 
I'll file a bug for that once I have a patch ready.

diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index de432e4e1c3..684763061e0 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -419,7 +419,7 @@ vc-annotate
 		       (read-string (format-prompt "Annotate span days" 20)
 				    nil nil "20"))))))))
   (setq vc-annotate-display-mode display-mode) ;Not sure why.  --Stef
-  (let* ((temp-buffer-name (format "*Annotate %s (rev %s)*" (buffer-name) rev))
+  (let* ((temp-buffer-name (format "*Annotate %s (rev %s)*" (buffer-name vc-parent-buffer) rev))
          (temp-buffer-show-function 'vc-annotate-display-select)
          ;; If BUF is specified, we presume the caller maintains current line,
          ;; so we don't need to do it here.  This implementation may give