wyuenho / all-the-icons-dired

Adds dired support to all-the-icons
GNU General Public License v3.0
23 stars 6 forks source link

Avoid calling `file-directory-p` on remote files #20

Open Stebalien opened 8 months ago

Stebalien commented 8 months ago

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 (re-search-backward
           dired-permission-flags-regexp nil t)
          (setq file-type (char-after (match-beginning 1))

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:

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.

wyuenho commented 8 months ago

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.