From 4ff9db05b20ac48b222b06f6c11a12fd35fdcdec Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Tue, 22 Nov 2022 16:45:30 -0300 Subject: [PATCH 1/1] New option vc-annotate-buffer-name-function * lisp/vc/vc-annotate.el (vc-annotate-buffer-name-function): New user option. (vc-annotate-buffer-name-default): New function to compute the default name of VC-Annotate buffers. (vc-annotate): Use `vc-annotate-buffer-name-function'. * etc/NEWS: Announce the new user option. --- etc/NEWS | 5 +++++ lisp/vc/vc-annotate.el | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 5a65896d69..01dab3387b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1973,6 +1973,11 @@ your mail user agent. The behavior of 'vc-prepare-patch' can be modified by the user options 'vc-prepare-patches-separately' and 'vc-default-patch-addressee'. ++++ +*** New user option 'vc-annotate-buffer-name-function'. +It allows setting a custom function to format the name of VC-Annotate +buffers. + ** Message --- diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index a15cf417de..ff3c9905d1 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el @@ -162,6 +162,22 @@ vc-annotate-menu-elements :type '(repeat number) :group 'vc) +(defcustom vc-annotate-buffer-name-function #'vc-annotate-buffer-name-default + "Function to compute the name of a VC-Annotate buffer. +The function receives two arguments, the buffer being annotated +and the revision as string. It should return the VC-Annotate +buffer name as string." + :type 'function + :group 'vc + :version "29.1") + +(defun vc-annotate-buffer-name-default (buffer revision) + "Function to compute the default name of a VC-Annotate buffer. +See `vc-annotate-buffer-name-function'." + (format "*Annotate %s (rev %s)*" + (buffer-name buffer) + revision)) + (defvar-keymap vc-annotate-mode-map :doc "Local keymap used for VC-Annotate mode." "a" #'vc-annotate-revision-previous-to-line @@ -409,7 +425,9 @@ vc-annotate nil nil "20"))))))) (vc-ensure-vc-buffer) (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 (funcall vc-annotate-buffer-name-function + (current-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 -- 2.34.1