Subject: Re: bug#18535: tramp alters `vc-handled-backends'

From: Emilio Lopes <[email-masked]>
Date: Thu, 25 Sep 2014 09:10:04 +0200

2014-09-23 17:37 GMT+02:00 Stefan Monnier <[email-masked]>:
>> `tramp-sh-handle-vc-registered' can permanently alter the value of
>> `vc-handled-backends' causing Emacs to stop recognizing version
>> controlled files as such.  This happened to me a couple of times after
>> having pressed `C-g' while some `tramp' operation was apparently
>> hanging.
>
> The current code uses a `let' binding, which uses the same mechanism as
> unwind-protect, so I don't think that's the source of a the problem.

Is this common behavior in Lisps?  I could not find any reference to
this in the Elisp manual.

Anyway, thanks for point this out!

> The `delq' look dangerous on the other hand.  Shouldn't these be
> `remq' instead?

yes, this seems to solve the problem.

=== modified file 'lisp/net/tramp-sh.el'
--- lisp/net/tramp-sh.el    2014-09-08 15:52:04 +0000
+++ lisp/net/tramp-sh.el    2014-09-25 07:07:25 +0000
@@ -3464,19 +3464,19 @@
              (not (with-tramp-connection-property v vc-bzr-program
                 (tramp-find-executable
                  v vc-bzr-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Bzr vc-handled-backends)))
+        (setq vc-handled-backends (remq 'Bzr vc-handled-backends)))
       (when (and (memq 'Git vc-handled-backends)
              (boundp 'vc-git-program)
              (not (with-tramp-connection-property v vc-git-program
                 (tramp-find-executable
                  v vc-git-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Git vc-handled-backends)))
+        (setq vc-handled-backends (remq 'Git vc-handled-backends)))
       (when (and (memq 'Hg vc-handled-backends)
              (boundp 'vc-hg-program)
              (not (with-tramp-connection-property v vc-hg-program
                 (tramp-find-executable
                  v vc-hg-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Hg vc-handled-backends)))
+        (setq vc-handled-backends (remq 'Hg vc-handled-backends)))
       ;; Run.
       (ignore-errors
         (tramp-run-real-handler 'vc-registered (list file))))))))