tramp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

extracting remote directory without depending on tramp


From: chris warth
Subject: extracting remote directory without depending on tramp
Date: Thu, 6 Jul 2017 22:06:23 -0700

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]