Is there a correct way to extract just the directory path of a file
buffer that may be a remote tramp file?  I''m trying to fix up the
`goimport` handling in go-mode.

Current code uses

(file-name-directory (file-truename buffer-file-name))

which leaves "/ssh:remote:" on the front of the directory name., e.g.
"/ssh:remote:/mnt2/source/go/src/github.com/username/"

I've hacked it by using,

(file-name-directory
    (tramp-file-name-localname
          (tramp-dissect-file-name buffer-file-name))

That seems to return just the directory portion of the remote path, eg
"/mnt2/source/go/src/github.com/username/"

But that puts a dependency on tramp in the middle of go-mode.

Is there a blessed way to do this type of thing?

Thanks in advance,

- Chris

_______________________________________________
Tramp-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to