From: Juri Linkov Date: Tue, 14 Nov 2023 07:44:15 +0000 (+0200) Subject: * lisp/vc/vc.el (vc-deduce-backend-nonvc-modes): New variable (bug#67145). X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7d42a76234ea5ca417915f8d5d755cc1f5aae7e5;p=emacs.git * lisp/vc/vc.el (vc-deduce-backend-nonvc-modes): New variable (bug#67145). (vc-deduce-backend): Use it. --- diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 95f9218dcbf..d768af678c3 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1071,14 +1071,20 @@ Within directories, only files already under version control are noticed." (defvar diff-vc-backend) (defvar diff-vc-revisions) +;; Maybe we could even use comint-mode rather than shell-mode? +(defvar vc-deduce-backend-nonvc-modes + '(dired-mode shell-mode eshell-mode compilation-mode) + "List of modes not supported by VC where backend should be deduced. +In these modes the backend is deduced based on `default-directory'. +When nil, the backend is deduced in all modes.") + (defun vc-deduce-backend () (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend) ((derived-mode-p 'log-view-mode) log-view-vc-backend) ((derived-mode-p 'log-edit-mode) log-edit-vc-backend) ((derived-mode-p 'diff-mode) diff-vc-backend) - ;; Maybe we could even use comint-mode rather than shell-mode? - ((derived-mode-p - 'dired-mode 'shell-mode 'eshell-mode 'compilation-mode) + ((or (null vc-deduce-backend-nonvc-modes) + (apply #'derived-mode-p vc-deduce-backend-nonvc-modes)) (ignore-errors (vc-responsible-backend default-directory))) (vc-mode (vc-backend buffer-file-name))))