unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67145: Modes in vc-deduce-backend
@ 2023-11-13  7:07 Juri Linkov
  2023-11-13 14:11 ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2023-11-13  7:07 UTC (permalink / raw)
  To: 67145

[-- Attachment #1: Type: text/plain, Size: 149 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vc-deduce-backend-modes.patch --]
[-- Type: text/x-diff, Size: 995 bytes --]

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#67145: Modes in vc-deduce-backend
  2023-11-13  7:07 bug#67145: Modes in vc-deduce-backend Juri Linkov
@ 2023-11-13 14:11 ` Dmitry Gutov
  2023-11-13 17:29   ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2023-11-13 14:11 UTC (permalink / raw)
  To: Juri Linkov, 67145

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?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67145: Modes in vc-deduce-backend
  2023-11-13 14:11 ` Dmitry Gutov
@ 2023-11-13 17:29   ` Juri Linkov
  2023-11-13 21:22     ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2023-11-13 17:29 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 67145

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67145: Modes in vc-deduce-backend
  2023-11-13 17:29   ` Juri Linkov
@ 2023-11-13 21:22     ` Dmitry Gutov
  2023-11-14  7:46       ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2023-11-13 21:22 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 67145

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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67145: Modes in vc-deduce-backend
  2023-11-13 21:22     ` Dmitry Gutov
@ 2023-11-14  7:46       ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2023-11-14  7:46 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 67145

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?





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-11-14  7:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13  7:07 bug#67145: Modes in vc-deduce-backend Juri Linkov
2023-11-13 14:11 ` Dmitry Gutov
2023-11-13 17:29   ` Juri Linkov
2023-11-13 21:22     ` Dmitry Gutov
2023-11-14  7:46       ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).