I use tramp to connect to my company's servers. I would like to customize my functions to work differently if I am accessing local files vs remote ones.
Is there a variable I could check if the buffer I am accessing is on a remote server or my local machine?
Something like:
if(TRAMP_CONNECTED)
Do this
else
Do that
file-directory-p
-- the doc-string is as follows:(file-directory-p FILENAME)
-- Returnt
if FILENAME names an existing directory. Symbolic links to directories count as directories. Seefile-symlink-p
to distinguish symlinks. Depending on the usage, you might also be interested inbuffer-file-name
as a variable or(buffer-file-name)
as a function -- both are usually set when there is a file; however, some modes set a non-file-visiting buffer equal to a specificbuffer-file-name
. – Dexterbuffer-file-name
is sometimes set by some modes for non-file-visiting buffers. The doc-string for the functionbuffer-file-name
states: Return name of file BUFFER is visiting, or nil if none -- No argument or nil as argument means use the current buffer. I have not yet seen an example where the value would be different between the variable or the function that returns the value. – Dexter