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.
This commit is contained in:
Lars Ingebrigtsen 2021-12-06 06:41:25 +01:00
parent 9ab479b639
commit 0dca455d14
2 changed files with 16 additions and 1 deletions

View file

@ -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

View file

@ -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