Subject: bug#46459: 28.0.50; Shared keymap for Git VC dir "Branch" header?

From: Protesilaos Stavrou <[email-masked]>
Date: Fri, 12 Feb 2021 08:54:13 +0200

Dear maintainers,

In vc-git.el the header for vc-dir stashes is propertized with its own
keymap.  This means that while point is over the value of the "Stash:"
header, the specified keymap comes into effect, instead of the main one
for vc-dir.  The latter takes effect when point is anywhere but that
header's value.

Should this principle be applied to the value of the "Branch" header as
well?  The attached patch is a proof-of-concept to that end.

If you believe this is worth doing, what else do you think should go
into such a patch from a usability standpoint?

All the best,
Protesilaos

-- 
Protesilaos Stavrou
protesilaos.com
>From 8945cf63f2fc16881b95ed5be209885b73b9449f Mon Sep 17 00:00:00 2001
Message-Id: <[email-masked]>
From: Protesilaos Stavrou <[email-masked]>
Date: Fri, 12 Feb 2021 08:40:33 +0200
Subject: [PATCH] Add shared keymap to Git VC dir "Branch" header

* lisp/vc/vc-git.el (vc-git-branch-shared-map): Define new keymap.
(vc-git-dir-extra-headers): Propertize header with new keymap.
---
 lisp/vc/vc-git.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 25ae26d746..030af2a379 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -656,6 +656,13 @@ vc-git-dir-status-files
                                  :files files
                                  :update-function update-function)))
 
+(defvar vc-git-branch-shared-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "c" 'vc-create-tag)
+    (define-key map "l" 'vc-print-branch-log)
+    (define-key map "t" 'vc-retrieve-tag)
+    map))
+
 (defvar vc-git-stash-shared-map
   (let ((map (make-sparse-keymap)))
     (define-key map "S" 'vc-git-stash-snapshot)
@@ -814,7 +821,8 @@ vc-git-dir-extra-headers
     (concat
      (propertize "Branch     : " 'face 'vc-dir-header)
      (propertize branch
-		 'face 'vc-dir-header-value)
+		 'face 'vc-dir-header-value
+                 'keymap vc-git-branch-shared-map)
      (when remote-url
        (concat
 	"\n"
-- 
2.30.0