Does tramp provide any API for polling information from the file name buffer-file

I am currently doing a lot of work on remote vagrant machines. However, the project logic gets confused when building command-line commands, because it will try to connect to some path / ssh: blah .....

Does tramp provide any API functions to check if the buffer or buffer file name is really controlled by a tramp and therefore on a remote machine? Can it provide additional information about the type of connection (e.g. ssh user / host data)?

+4
source share
2 answers

Regarding your first question about checking if the tramp file name is controlled, see the tramp-tramp-file-p function, which will return t if filename is a tramp file.

+5
source

The tramp-file-name-regexp variable is used to match Tramp file names. (edit: see erikriverson's description below for a more convenient way of matching this.)

This is added to file-name-handler-alist (which defines a handler for all file names) and is associated with tramp-file-name-handler , so you can alternatively check 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 doesn't matter).

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

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

+2
source

All Articles