Paul Northug <[email protected]> writes:

> Hi Michael. 

Hi Paul,

> python-mode.el uses py-temp-directory to define a filename for writing
> the region, as you pointed out:
>
> (file (concat (expand-file-name temp py-temp-directory) ".py"))
>
> I added a line below:
>
> (tramp-file (concat (expand-file-name temp (concat tramp-py-prefix
> py-temp-directory)) ".py"))
>
> and hard-coded tramp-py-prefix in my .emacs: (setq tramp-py-prefix
> "/ssh:paul@localhost#9999:")
>
> And I used 'tramp-file' in the places where the buffer was being
> written and 'file' where it was being executed.
>
> Can you point to any example code on how to detect I if am using tramp
> and modify the filenames accordingly?

Every buffer has a buffer-local variable default-directory. You can
check whether this is a remote directory with the function
file-remote-p. If this returns non-nil, it is remote.

Even better, file-remote-p returns exactly the remote part of a file
name. Like this:

(file-remote-p "/tmp") => nil
(file-remote-p "/ssh:paul@localhost#9999:/tmp") => "/ssh:paul@localhost#9999:"

Let's also simplify and assume that the temp directory is always the
same on all involved hosts, for example "/tmp". py-temp-directory shall
keep this value.

In this case, you could replace all occurences of py-temp-directory by

(concat (file-remote-p default-directory) py-temp-directory)

Best regards, Michael.

_______________________________________________
Tramp-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to