Subject: bug#67145: Modes in vc-deduce-backend

From: Juri Linkov <[email-masked]>
Date: Mon, 13 Nov 2023 09:07:32 +0200

Here is a patch that avoids hard-coding the modes in vc-deduce-backend.
For example, it makes possible to replace shell-mode with comint-mode, etc.

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 95f9218dcbf..9c01f032fc0 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1071,14 +1071,16 @@ log-edit-vc-backend
 (defvar diff-vc-backend)
 (defvar diff-vc-revisions)
 
+;; Maybe we could even use comint-mode rather than shell-mode?
+(defvar vc-deduce-backend-modes '(dired-mode shell-mode eshell-mode compilation-mode))
+
 (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-modes)
+             (apply #'derived-mode-p vc-deduce-backend-modes))
 	 (ignore-errors (vc-responsible-backend default-directory)))
 	(vc-mode (vc-backend buffer-file-name))))