tramp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting TRAMP 2.0.25 working in NT Emacs 21.2.1 with Cygwin 1.3.12-1


From: Francis Litterio
Subject: Getting TRAMP 2.0.25 working in NT Emacs 21.2.1 with Cygwin 1.3.12-1
Date: Mon, 07 Oct 2002 18:09:41 -0400
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (i386-msvc-nt5.0.2195)

I got TRAMP 2.0.25 to work under NT Emacs 21.2.1 using the latest
installation of the Cygwin tools (1.3.12-2) using Cygwin's ssh, scp, and
ssh-agent.  The remote host was running Debian GNU/Linux.  I haven't
been brave enough to try a Cygwin-to-Cygwin configuration yet -- I think
Cygwin-to-UNIX is more common anyway.  Also, I didn't try getting the
"telnet" method to work, on the theory that using scp is more common.

Here's what I had to do to make it work:

1. In my .emacs startup file, I do:

        (require 'tramp)
        (setq tramp-default-method "scpx")

   This is required when using TRAMP under NT Emacs as described in the
   manual.

   to load up TRAMP.  I have load-path set appropriately.

2. Next, my .emacs file executes this horror:

        (let ((shell-file-name "c:/apps/cygwin/bin/bash.exe"))
          (shell-command "echo /tmp/ssh-*/agent.* 2>/dev/null" " *temp*"))
        (save-excursion
          (set-buffer " *temp*")
          (end-of-line)
          (if (> (buffer-size) 5)
              (setenv "SSH_AUTH_SOCK" (buffer-substring (point-min) (point)))
            (ding)
            (message "my-general.el: WARNING: ssh-agent is not running!")
            (sit-for 3)))

   The above mess is to cope with what I think is a fairly common
   situation -- namely, where the user launches NT Emacs using a
   shortcut on the desktop but starts ssh-agent from a bash shell also
   launched from the desktop.  Since Emacs is not a descendant of
   ssh-agent, it does not inherit the SSH_AUTH_SOCK environment
   variable (and neither does scp).

   My solution (above) is a total hack.  It malfunctions if the echo
   command outputs more than one pathname, which happens if you have old
   ssh-agent socket directories lying around.  If TRAMP had were to call
   a hook at just the right moment, I could write some Elisp to find the
   most recent ssh-agent socket file and setenv the SSH_AUTH_SOCK
   environment variable within Emacs.

   Maybe the general solution is to create a tramp-methods key named
   tramp-pre-rcp-hook, which is run just before tramp-rcp-program
   executes?

3. Next, I had to make the following change to lisp/tramp.el.

        ***************
        *** 3113,3118 ****
        --- 3113,3119 ----
            "Like `insert-file-contents' for tramp files."
            (barf-if-buffer-read-only)
            (setq filename (expand-file-name filename))
        +   (setq buffer-file-name filename)
            (with-parsed-tramp-file-name filename nil
              (when (tramp-ange-ftp-file-name-p multi-method method user host)
                (tramp-invoke-ange-ftp 'insert-file-contents

   This may not be the right thing to do, but it prevents a
   wrong-type-argument error from vc-file-not-found-hook and from
   find-file-noselect-1 when they each evaluate (file-truename
   buffer-file-name) with buffer-file-name set to nil.

4. Next, I had to make the following change to lisp/tramp.el.

        *** 3024,3030 ****
                (unless (file-exists-p filename)
                (error "Cannot make local copy of non-existing file `%s'"
                       filename))
        !       (setq tmpfil (tramp-make-temp-file))
                (cond (rcp-program
                     ;; Use rcp-like program for file transfer.
                     (tramp-message-for-buffer
        --- 3024,3030 ----
                (unless (file-exists-p filename)
                (error "Cannot make local copy of non-existing file `%s'"
                       filename))
        !       (setq tmpfil (substring (tramp-make-temp-file) 2))
                (cond (rcp-program
                     ;; Use rcp-like program for file transfer.
                     (tramp-message-for-buffer

   This is to cope with the fact that, by default, NT Emacs has
   temporary-file-directory set to C:/DOCUME~1/username/LOCALS~1/Temp/,
   which is unacceptable to Cygwin's scp as the second argument, because
   scp interprets the "c:" as a hostname!  The substring call chops off
   the "C:", leaving tmpfil set to a value that is acceptable to both
   Cygwin's scp and NT Emacs (and, more importantly, means the same
   thing to both of them).

   This change doesn't pass the "smell test" to me, but it probably
   works 99% of the time.  I haven't thought of a more general solution
   yet.

I hope this helps.
--
Francis Litterio
address@hidden
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]