bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51622: 29.0.50; [PATCH v3] Abbreviate remote home directories in `ab


From: Jim Porter
Subject: bug#51622: 29.0.50; [PATCH v3] Abbreviate remote home directories in `abbreviate-file-name'
Date: Sun, 14 Nov 2021 22:58:31 -0800

On 11/14/2021 6:43 AM, Michael Albinus wrote:
Thanks. However, I believe this test shall be called
`files-tests-file-name-non-special-file-abbreviate-file-name', like the
other non-special tests. And perhaps it shall be located prior
`files-tests-file-name-non-special-access-file'.

Ok, done.

Incidentally, another interesting
feature would be abbreviating default methods/users. That's probably
easy when Tramp has filled in those values since the file name has
`tramp-default' properties set. I'm not sure how tricky it would be to
do without those properties though.

You cannot trust the `tramp-default' property. It is set when a method
or user or host name is expanded as in "/ssh::". But when the host name
is used explicitly by the user, as in "/ssh:host:", the property is not
set, even if "host" is the default. Same for user.

But it shouldn't be too hard to determine the defaults. We have
tramp-default-method{-alist}, tramp-default-user{-alist}, and
tramp-default-host{-alist}. All needed information is there.

Right, that confirms what I suspected. I'll try to look into this in more detail later when I get the chance.

I also attached a slightly-updated benchmark script as well as new
results. Performance on local file names is the same as before the
patch, and just slightly faster than before with Tramp file
names. (Most of the performance improvements here happened in
bug#51699, so I mainly wanted to maintain the current performance in
this patch.)

Good, no regression :-)

Fixing your comments below *did* regress performance for abbreviating Tramp file names compared to current master (it takes 1.47x as long now in the worst case), but it's still considerably faster than Emacs 28. I've attached updated benchmark results to show the difference.

This shall be rather "---". We don't add documentation (yet) for this
new Tramp feature.

Fixed.

+*** Tramp supports abbreviating remote home directories now.
+When calling 'abbreviate-file-name' on a Tramp filename, the result
+will abbreviate the home directory to "~".

This might be misleading. ... the result will abbreviate the remote home
directory to "/ssh:user@host:~" (for example).

Ok, I tried to make this section clearer.

Well, I believe we can implement abbreviation also for other Tramp
backends, like in tramp-sudoedit.el. So it might be better to call this
handler `tramp-handle-abbreviate-file-name'.

Done. I added this for the sudoedit and smb methods, since both support
"~" expansion in `expand-file-name'. That *should* be sufficient, but I've never used either of those methods, so I could be wrong...

Please use `case-insensitive-p'. We don't know whether there will be
other implementation for this magic function in the future. And we shall
not bypass the checks in `tramp-file-name-handler', which are important
for parallel invocations of Tramp handlers.

Fixed (same with `expand-file-name'). These changes slow things down a fair bit, but that's mostly due to checking for the right file name handler more often. Like I said above though, it's still a lot faster than Emacs 28 (thanks to bug#51699).

Attachment: 0001-Add-another-abbreviate-file-name-test.patch
Description: Text document

Attachment: 0002-Support-abbreviating-home-directory-of-Tramp-filenam.patch
Description: Text document

Attachment: benchmark-results.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]