开发者

Does tramp offer any API for interrogating information from the buffer-file-name

I'm currently doing a lot of work on remote machines with tramp. However the project logic gets confused when building make command lines as it will attempt to cd to some /ssh:blah.... path.

Does tramp provide any API functions to test if a buffer or a buffer filename is actually managed by tramp and therefor on a remote machine? Can it provide additional information about the type of connection (for example 开发者_如何学Pythonssh user/host details)?


As to your first question about checking if a filename is managed by tramp, see the function tramp-tramp-file-p, which will return t if filename is a tramp file.


The variable tramp-file-name-regexp is used to match Tramp-like filenames. (edit: see erikriverson's answer below for a more convenient way to match against this.)

This is added to file-name-handler-alist (which determines the handler for all filenames), and associated with tramp-file-name-handler, so you could alternatively test the return value of the find-file-name-handler function to see whether it matches. This seems like a slightly more robust method (although in practice it probably makes no difference).

(eq (find-file-name-handler filename nil) 'tramp-file-name-handler)

(tramp-dissect-file-name filename) will then return the individual connection components (also see the tramp-file-name-structure variable).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜