[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix hostname completion on MS Windows
From: |
Michael Albinus |
Subject: |
Re: [PATCH] Fix hostname completion on MS Windows |
Date: |
Thu, 08 Apr 2021 14:40:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jim Porter <jporterbugs@gmail.com> writes:
Hi Jim,
> This patch resolves an MS Windows-specific issue with file name
> completion for Tramp: currently, when trying to complete a Tramp
> hostname (or method/user), it fails to match anything on MS Windows
> (however, completing the remote path works ok). This is because
> `file-name-completion' provides handlers with an absolute path to
> match against, but on MS Windows, that means the path starts with the
> volume letter, e.g. "c:/ssh:host:/path/to/file".
I don't mind to apply such a patch, but I haven't heard about this kind
of file name completion to "c:/ssh:host:/path/to/file". Could you pls
show an example, and what you have typed in order to get this?
Best might be to enable Tramp traces after loading Tramp, like
--8<---------------cut here---------------start------------->8---
(require 'trace)
(dolist (elt (all-completions "tramp-" obarray 'functionp))
(trace-function-background (intern elt)))
(untrace-function 'tramp-read-passwd)
--8<---------------cut here---------------end--------------->8---
Then run the test, and disable traces afterwards
--8<---------------cut here---------------start------------->8---
(untrace-all)
--8<---------------cut here---------------end--------------->8---
There will be a new buffer *trace-output*, which shall tell us the
story.
> The attached patch fixes things for me; it's somewhat hacky, since it
> tries to recognize the mutilated path string as shown above.
That would be OK, but perhaps we make the volume letter optional? Like
--8<---------------cut here---------------start------------->8---
(when (eq system-type 'windows-nt)
"\\(?:[[:alpha:]]:\\)?")
--8<---------------cut here---------------end--------------->8---
> However, changing that would (probably) be an invasive change to how
> core Emacs handles file name completion. This also mirrors the
> behavior of `tramp-drop-volume-letter', so hopefully it's ok. I
> *think* this only applies to windows-nt systems and not cygwin (which
> usually uses *nix-style paths), but I don't have Cygwin installed so I
> didn't try it there.
I know, that Eli Zaretskii (maintainer of Emacs) has committed several
patches in order to drop such a volume letter for remote file names, but
I don't remember where they have been applied. Perhaps, this was an
Emacs 28 change.
> I don't have copyright assignment papers filled out, but hopefully
> this patch is small enough that that's not necessary. If you think it
> is, just let me know and I'll get that handled.
This patch is small enough (the upper limit are ~15 lines), but in
general it is a good idea to sign copyright papers for future
changes. To start the assignment process you should download
https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/Copyright/request-assign.future
and return the completed information to the address at the top.
> As a small addendum: this patch still doesn't fix things when
> `default-directory' is a UNC path (e.g. "\\server\mnt\"), but the same
> issue applies to `tramp-drop-volume-letter', and this case should be
> rare in practice anyway.
Yep, we could handle this case afterwards. If needed.
> - Jim
Best regards, Michael.