From 0dca455d1446eb7743594b3202b55e57615915c9 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 6 Dec 2021 06:41:25 +0100 Subject: [PATCH] Make the Git stash commands available in vc-dir Git buffers * lisp/vc/vc-dir.el (vc-dir): Call the backend-specific minor mode if it exists. * lisp/vc/vc-git.el (vc-dir-git-mode-map): New map. (vc-dir-git-mode): New minor mode. --- lisp/vc/vc-dir.el | 7 ++++++- lisp/vc/vc-git.el | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 8165d5e09f1..32e492171d3 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -1427,7 +1427,12 @@ These are the commands available for use in the file status buffer: (vc-dir-refresh) ;; FIXME: find a better way to pass the backend to `vc-dir-mode'. (let ((use-vc-backend backend)) - (vc-dir-mode)))) + (vc-dir-mode) + ;; Activate the backend-specific minor mode, if any. + (when-let ((minor-mode + (intern-soft (format "vc-dir-%s-mode" + (downcase (symbol-name backend)))))) + (funcall minor-mode 1))))) (defun vc-default-dir-extra-headers (_backend _dir) ;; Be loud by default to remind people to add code to display diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 08282647eb0..3ceed365ee0 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1872,6 +1872,16 @@ Returns nil if not possible." (1- (point-max))))))) (and name (not (string= name "undefined")) name)))) +(defvar-keymap vc-dir-git-mode-map + "z c" #'vc-git-stash + "z s" #'vc-git-stash-snapshot) + +(define-minor-mode vc-dir-git-mode + "A minor mode for git-specific commands in `vc-dir-mode' buffers. +Also note that there are git stash commands available in the +\"Stash\" section at the head of the buffer." + :lighter " Git") + (provide 'vc-git) ;;; vc-git.el ends here -- 2.39.2