I realize you're asking to detect tramp buffers vs, say, files on a remote mounted filesystem, but for posterity this might be useful to other searchers:
(defun buffer-is-on-local-fs-p ()
(and (buffer-file-name)
(let ((local-path (chomp (shell-command-to-string
(concat "df -l \"" (buffer-file-name) "\" | awk '/^Filesystem/ {next}; {print $6}'")))))
(not (string= "" local-path)))))
This uses unix's df
to identify the filesystem hosting the full path of the current buffer, and then makes a best-effort to determine what its mount type is. It's not perfect, but it's served me pretty well (I used to use it to gate VC mode funcionality, which was painfully slow on remote filesystems).