Wednesday, October 10, 2012

Emacs + putty + TRAMP = you can edit your UNIX files remotely on Windows

TRAMP User Manual

TRAMP extends the capabilities of the emacs "directory editor" (dired) to allow you to also deal with remote files. "Remote" as in:

  • you can reach the file or directory through ssh
  • or sftp
  • or ftp
  • or …
SSH on Windows – PuTTY:
On Windows platforms it can make use of the PuTTY family of utilities in order to achieve ssh and sftp tasks.

The TRAMP user manual recommends using scpc resp. pscpc instead of ssh resp. (just) plink for dealing with large files [Link]. I suggest you go for this recommendation anyway. Really! I mean it! According to my experience (having tried various ways resp. methods) plink resp. plinkx occasionally corrupt files, and you avoid that using the TRAMP method pscp, which is actually a nice combination of plinkx and PuTTY pscp, i.e. you are passing a named saved session rather than a host name to it. ("THE manual" does not mention this bit, but you should be aware of it.)

On the Windows PC at my customer's site I am not able to modify my system environment.
The putty directory is not put on PATH by the system, I am doing it within my .emacs.

Still: For some reason tramp does not search its tramp-copy-program on PATH, and at least pscp does not get found that way. The error message goes like this:
Cannot find copy program: pscp.
I found the variable tramp-methods and changed the resp. tramp-copy-program assoc to have pscp with its absolute path as its value instead of just pscptramp-methods cannot be "customized". add-to-list always only ends to the end of the list, so just adding a new try with a full-path-pscp would not have helped, so I rather changed .../emacs/lisp/net/tramp-loaddefs.el. Quick and dirty, I know. I will find a more appropriate way occasionally, I promise.

Update 2013-01-15: tramp paths with ports:
Occasionally "sitting" on a VM (VirtualBox) host I copy / access files living in a VM Linux guest, whose SSH port is forwarded to the VM host's port 2222.
VM-host $ env RSYNC_RSH='ssh -p 2222' rsync -vaz diary localhost:diary_
This is a useful emacs/tramp access path for those files:

scpx and sshx as opposed to scp and ssh (without the 'x' in the end) seem to accept a port number within these emacs/tramp access paths.

Update 2013-04-30: problem with preserving emacs tramp file permissions:
Somebody else experiences this problem as well [link].

Update 2013-04-30 evening: : I think, this doesn't concern TRAMP, as TRAMP has its own means to enquire and set file modes.

Update 2013-10-__:
Found "vc-handled-backends" and reduced it on my Windows emacs / tramp / putty platform.

No comments: