Subject: Re: bug#31489: 25.3; Dired unable to open directory "/ssh:example.com"

From: Michael Albinus <[email-masked]>
Date: Mon, 21 May 2018 19:53:55 +0200

Christoph Michelbach <[email-masked]> writes:

Hi Christoph,

> On Sun, 2018-05-20 at 20:30 +0200, Michael Albinus wrote:
>> You haven't answered my question: Could you live w/o Tramp, and set
>> tramp-mode to nil? Or do you want still use Tramp, and I shall extend
>> Tramp with an "exclude file names" feature?
>>
>> Both variants would be a solution for this.
>
> I haven't done so because I'm not suffering from this bug atm. I do use
> tramp but I don't have the problem described in the bug report in
> practice. I merely wanted to find out to what extent dired can be used
> as a file browser and explored some edge cases. While doing so, I found
> a few problems and this is the first one (and thus far only one found
> while explicitly looking for bugs) I have reported. To evade the
> problem in practice, one could simply use symlinks for the folders with
> the weird names. Or one could use a single simlink created via
>
> sudo ln -s / /f
>
> and then always start at "/f".

That was my first idea, when reading your bug report. But it doesn't
work. `file-truename' would convert any file name
"/f/ssh:example.com:/..." into "/ssh:example.com:/...", and we're back
to the problem.

> Evading this problem in practice is simple, but it seems to me that
> HAVING to evade it shows poor usability.

The problem is not related to dired. It comes from how file name
handlers are designed in Emacs. They are active only based on the file
*name*, not on anything else of the related file. That means, any file
*name* which matched Tramp's remote file name syntax, activates Tramp.

>> I don't see how this could be avoided. Of course, dired could quote any
>> directory name with "/:" when opening a directory with a file name
>> dedicated to Tramp (or another file name handling library). But this
>> would discard *any* file name handlers in this subdirectory, including
>> something like uncrompressing files, as jka-compr does, or decrypting
>> files, whis is performed by epa.
>
> So the problem is that this way of quoting is also used in different
> places, which means that it's not possible to view the contents of
> "/ssh:example.com/tarball.tar" in Emacs without removing tramp /
> disabling tramp / adding an exception for this specific path?

Well, viewing the contents of a *.tar file is not performed via a file
name handler, so it is possible to view the contents of
"/:/tmp/foo.tar", for example. See the variable `file-name-handler-alist'
for the file name handlers which are invoked via this mechanism, and
which would be disabled by quoting a file name (prefixing it with "/:").

(On the contrary, in Emacs 27.0.50, viewing the contents of a tar file
by the special file name syntax "/tmp/foo.tar/" could fail, when the
file name is quoted like "/:/tmp/foo.tar/".)

You might read (info "(elisp) Magic File Names") for further
information about the underlying mechanism.

---

Finally, I've pushed a patch to Emacs' master branch which should solve
your problem. Add the following line to your .emacs:

(setq tramp-ignored-file-name-regexp "\\`/ssh:example\\.com:")

That's it. Tramp's documentation tells something about.

Best regards, Michael.