sanel / monroe

Clojure nREPL client for Emacs
161 stars 21 forks source link

Support loading files when remotely editing via TRAMP #36

Closed lukaszkorecki closed 3 years ago

lukaszkorecki commented 3 years ago

I've noticed that monroe-load-file doesn't work when connecting to a remote nREPL server and editing files remotely via TRAMP. We get an error, assuming I'm editing "foor/bar/time.clj" on a remote host. (Paths are redacted btw, in case they don't look valid)

foor.core=> Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
/ssh:user@foobar:/home/ubuntu/project/foor/bar/time.clj (No such file or directory)

There's multiple ways to fix this it seems, but this function tramp-compat-file-local-name is the most suitable and it transparently handles local file paths:

(tramp-compat-file-local-name "/ssh:user@foobar:/home/ubuntu/project/foor/bar/time.clj")
; => "/home/ubuntu/project/foor/bar/time.clj"
(tramp-compat-file-local-name "/home/ubuntu/project/foor/bar/time.clj")
; => "/home/ubuntu/project/foor/bar/time.clj"

According to Emacs docs "TRAMP is included as part of Emacs (since Emacs 22.1)." so we should be safe to include this and not break anything for people not using TRAMP.

sanel commented 3 years ago

Thank you!