]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/vc.el (vc-deduce-backend-nonvc-modes): New variable (bug#67145).
authorJuri Linkov <juri@linkov.net>
Tue, 14 Nov 2023 07:44:15 +0000 (09:44 +0200)
committerJuri Linkov <juri@linkov.net>
Tue, 14 Nov 2023 07:44:42 +0000 (09:44 +0200)
(vc-deduce-backend): Use it.

lisp/vc/vc.el

index 95f9218dcbfceb77f4647c16b25f07834375f6dc..d768af678c34cd1d6ad68fb05366950cdb320bf0 100644 (file)
@@ -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))))