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

From: Stephen Berman <[email-masked]>
Date: Tue, 24 Jun 2025 13:50:18 +0200

On Tue, 24 Jun 2025 06:41:41 -0400 Kristoffer Balintona <[email-masked]> wrote:

> Hi,
>
> I've noticed a peculiarity with the names of the buffer created by
> vc-annotate. For instance, opening up vtable.el and calling vc-annotate,
> the initial vc-annotate buffer name is:
> 1. *Annotate vtable.el (rev f1737342518)*
> Then calling vc-annotate-prev-revision:
> 2. *Annotate *Annotate vtable.el (rev f1737342518)* (rev
> fdab542a56201b1581abdc0df940e0c50abde1c7)*
> Then calling vc-annotate-prev-revision again:
> 3. *Annotate *Annotate *Annotate vtable.el (rev f1737342518)* (rev
> fdab542a56201b1581abdc0df940e0c50abde1c7)* (rev
> 35e1ab970c1cfc6a1b62fbb920e0d2bb031765da)*
> and so on. As you can see, the file names become messy quickly.
>
> 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?

Steve Berman
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index de432e4e1c3..de0145276ee 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -419,7 +419,8 @@ 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* ((bufname (string-trim (buffer-name) "\\*Annotate " " (rev .*"))
+         (temp-buffer-name (format "*Annotate %s (rev %s)*" bufname 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