Unfortunately, file-directory-p tends to be very slow (and can hang in some cases) when invoked on remote machines.The simple fix is to just avoid calling this entirely on remote machines. A better fix is to use the output of POSIX mode string.
Specifically, if you look at dired-move-to-end-of-filename, you'll see the following code:
If called when point is at the beginning of a filename (after calling (dired-move-to-filename t)), this code will set file-type to one of:
- - regular file
d - directory
l - symlink
s - socket
p - pipe
c - character device
b - block device
Unfortunately, the l case (symlink) is a bit difficult to handle as it might be a link to a directory, or it might be a link to a file. Personally, I'd resolve the underlying file type when local, and just display some generic "link" icon when remote. But there's no "right" way to handle that case.
Thanks for the report. Please feel free to send over a PR as I don't have any use case for looking at a remote directory from Emacs, so it's hard for me to gauge how slow it is or whether any fix is correct.
Unfortunately,
file-directory-p
tends to be very slow (and can hang in some cases) when invoked on remote machines.The simple fix is to just avoid calling this entirely on remote machines. A better fix is to use the output of POSIX mode string.Specifically, if you look at
dired-move-to-end-of-filename
, you'll see the following code:If called when
point
is at the beginning of a filename (after calling(dired-move-to-filename t)
), this code will setfile-type
to one of:-
- regular filed
- directoryl
- symlinks
- socketp
- pipec
- character deviceb
- block deviceUnfortunately, the
l
case (symlink) is a bit difficult to handle as it might be a link to a directory, or it might be a link to a file. Personally, I'd resolve the underlying file type when local, and just display some generic "link" icon when remote. But there's no "right" way to handle that case.