rainstormstudio / nerd-icons.el

GNU General Public License v3.0
206 stars 22 forks source link

nerd-icons-icon-for-dir hangs on remote hosts #74

Closed andrewpeck closed 3 months ago

andrewpeck commented 3 months ago

Hi-- I recently ran into issues with emacs hanging and traced it down to nerd-icons.el

The issue is with the call to (expand-file-name dir) when the dir is remote which I encountered e.g. with nerd icons in consult

I reproduced this on vanilla emacs 28.3 and 29.1 with the only installed package being nerd icons running in batch mode:

emacs  --batch --directory ~/nerd-icons.el/ -l ~/nerd-icons.el/nerd-icons.el -Q --eval "(print (nerd-icons-icon-for-dir \"/sshx:cobweb:~/\"))"

This hangs for a very long time (~1 minute per call) if the remote host is not available, and even when it available it is very slow since it is opening an SSH connection to retrieve each icon.

I am working around this by just replacing (expand-file-name dir) with (if (file-remote-p dir) dir (expand-file-name dir)) but there is probably a better solution.

Any thoughts?

Thank you,

Andrew

seagle0128 commented 3 months ago

How about (nerd-icons-icon-for-dir (file-local-name "/sshx:cobweb:~/"))?

andrewpeck commented 3 months ago

file-local-name is fast as well, no calls to tramp, but the behavior is different---

In the cond that sets the icon, with file-local-name is just falls back to the default case (since file-remote-p now returns nil because sshx:cobweb:~/ has just become `~/', indistinguishable from a local path) and I get an icon that looks like a folder whereas before it would take the first clause of the cond show a different icon for remote directories.

Thank you.

andrewpeck commented 3 months ago

Thanks so much for the prompt fix. It works great! :partying_face: