GNU bug report logs - #67145
Modes in vc-deduce-backend

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Mon, 13 Nov 2023 07:10:01 UTC

Severity: normal

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67145 in the body.
You can then email your comments to 67145 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#67145; Package emacs. (Mon, 13 Nov 2023 07:10:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 13 Nov 2023 07:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Modes in vc-deduce-backend
Date: Mon, 13 Nov 2023 09:07:32 +0200
[Message part 1 (text/plain, inline)]
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.

[vc-deduce-backend-modes.patch (text/x-diff, inline)]
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))))
 

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67145; Package emacs. (Mon, 13 Nov 2023 14:13:01 GMT) Full text and rfc822 format available.

Message #8 received at 67145 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Juri Linkov <juri <at> linkov.net>, 67145 <at> debbugs.gnu.org
Subject: Re: bug#67145: Modes in vc-deduce-backend
Date: Mon, 13 Nov 2023 16:11:34 +0200
On 13/11/2023 09:07, Juri Linkov wrote:
> 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.

Look good, although it would be great to find a more meaningful name: 
what kind of modes exactly should be in that list. Non-file-visiting?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67145; Package emacs. (Mon, 13 Nov 2023 17:32:02 GMT) Full text and rfc822 format available.

Message #11 received at 67145 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 67145 <at> debbugs.gnu.org
Subject: Re: bug#67145: Modes in vc-deduce-backend
Date: Mon, 13 Nov 2023 19:29:00 +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.
>
> Look good, although it would be great to find a more meaningful name:
> what kind of modes exactly should be in that list. Non-file-visiting?

These modes are non-file-visiting as well:

   (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)

What distinguishes these modes is that they are non-vc modes:

  '(dired-mode shell-mode eshell-mode compilation-mode)

Then maybe

  (defvar vc-deduce-backend-nonvc-modes




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67145; Package emacs. (Mon, 13 Nov 2023 21:24:02 GMT) Full text and rfc822 format available.

Message #14 received at 67145 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Juri Linkov <juri <at> linkov.net>
Cc: 67145 <at> debbugs.gnu.org
Subject: Re: bug#67145: Modes in vc-deduce-backend
Date: Mon, 13 Nov 2023 23:22:56 +0200
On 13/11/2023 19:29, Juri Linkov wrote:
> Then maybe
> 
>    (defvar vc-deduce-backend-nonvc-modes

Perhaps 'vc-supported-other-modes'? Anyway, your choice is already an 
improvement, please take your pick.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67145; Package emacs. (Tue, 14 Nov 2023 07:50:02 GMT) Full text and rfc822 format available.

Message #17 received at 67145 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 67145 <at> debbugs.gnu.org
Subject: Re: bug#67145: Modes in vc-deduce-backend
Date: Tue, 14 Nov 2023 09:46:50 +0200
close 67145 30.0.50
thanks

>> Then maybe
>>    (defvar vc-deduce-backend-nonvc-modes
>
> Perhaps 'vc-supported-other-modes'? Anyway, your choice is already an
> improvement, please take your pick.

The name should have the prefix 'vc-deduce-backend-*' that is essential.
So I pushed 'vc-deduce-backend-nonvc-modes' with more explanation in the
docstring.

Now I'm going to set it to nil to finally allow such useful cases as
'C-x p p C-x v L' even from *scratch*, Info, Gnus, and all other modes.

Or maybe 'project-switch-project' should let-bind this variable to nil?




bug marked as fixed in version 30.0.50, send any further explanations to 67145 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 14 Nov 2023 07:50:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 12 Dec 2023 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 150 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.