From bdfa9d64850e4b7de6b77dd16280a840ed0735fc Mon Sep 17 00:00:00 2001 From: Gabriel do Nascimento Ribeiro Date: Tue, 22 Nov 2022 16:50:35 -0300 Subject: [PATCH 1/1] New option vc-parent-buffer-name-format-function' * lisp/vc/vc-dispatcher.el (vc-parent-buffer-name-format-function): New user option to compute the parent buffer name identitication in mode-line of VC buffers. (vc-parent-buffer-name-format-default): New function to compute the default parent buffer name identitication in mode-line of VC buffers. (vc-setup-buffer, vc-start-logentry): Use `vc-parent-buffer-name-format-function'. * etc/NEWS: Announce the new user option. --- etc/NEWS | 5 +++++ lisp/vc/vc-dispatcher.el | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 5a65896d69..31bc22ab9e 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-parent-buffer-name-format-function'. +It allows setting a custom function to format the parent buffer name +identitication in mode-line of VC buffers. + ** Message --- diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index dc3ed52650..e45d4d16ef 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -142,6 +142,22 @@ vc-suppress-confirm :type 'boolean :group 'vc) +(defcustom vc-parent-buffer-name-format-function #'vc-parent-buffer-name-format-default + "Function to compute the parent buffer name identitication in +mode-line of VC buffers. +The function receives one argument, the parent buffer. It should +return the parent buffer name identitication as string." + :type 'function + :group 'vc + :version "29.1") + +(defun vc-parent-buffer-name-format-default (buffer) + "Function to compute the default parent buffer name identitication +in mode-line of VC buffers. +See `vc-parent-buffer-name-format-function'." + (format " from %s" + (buffer-name buffer))) + ;; Variables the user doesn't need to know about. (defvar vc-log-operation nil) @@ -188,7 +204,8 @@ vc-setup-buffer (kill-all-local-variables) (setq-local vc-parent-buffer camefrom) (setq-local vc-parent-buffer-name - (concat " from " (buffer-name camefrom))) + (funcall vc-parent-buffer-name-format-function + camefrom)) (setq default-directory olddir) (let ((buffer-undo-list t) (inhibit-read-only t)) @@ -748,7 +765,8 @@ vc-start-logentry (pop-to-buffer (get-buffer-create logbuf))) (setq-local vc-parent-buffer parent) (setq-local vc-parent-buffer-name - (concat " from " (buffer-name vc-parent-buffer))) + (funcall vc-parent-buffer-name-format-function + vc-parent-buffer)) (when patch-string (setq-local vc-patch-string patch-string)) (vc-log-edit files mode backend) -- 2.34.1