Is it possible to detect between remote and non-remote?
For buffers associated to files, there is file-remote-p.
For others, stackoverflow suggests using (file-remote-p default-directory).
I don't know how those behave if you use tramp to connect to a server which
then connects to the local host, or whether one using such connections would
not want that information to be as clearly visible as a remote host.