[Top][All Lists]

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

Re: Integrate Tramp

From: Kai Großjohann
Subject: Re: Integrate Tramp
Date: Thu, 20 Jun 2002 17:51:24 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (i686-pc-linux-gnu)

Richard Stallman <address@hidden> writes:

>     I suspect that whether you wanth to use tramp or ftp depends on both the
>     machine and the user; I would be happy with a variable that let me
>     specify mappings from these to the method to use (plus a default for
>     otherwise unspecified machines, of course).
> I think we need to implement this now, before the next release,
> because having two alternative syntaxes for remote file names is not a
> coherent interface.  It is usable for wizards, but not clean and nice.

I have now written some code which hooks into Ange-FTP.  For some
filenames, the Tramp functions instead of the Ange-FTP functions are
called.  (This is intended as a proof of concept, some changes would
be needed before it's included with Tramp.  It's not nice style to
just redefine the ange-ftp function...)

(require 'ange-ftp)

(defvar tramp-override-ange-ftp-alist
  '(("address@hidden" "sm"))
  "*Use Tramp for these Ange-FTP filenames.
Elements are (TARGET METHOD) where TARGET is a string of the form
\"address@hidden" and METHOD is a Tramp method name (also a string).")

(defun ange-ftp-hook-function (operation &rest args)
  (let* ((fn (get operation 'ange-ftp))
         (parsed-name (ange-ftp-ftp-name (car args)))
         (host (and parsed-name (nth 0 parsed-name)))
         (user (and parsed-name (nth 1 parsed-name)))
         (path (and parsed-name (nth 2 parsed-name)))
         (method (and user host
                      (assoc (format "address@hidden" user host)
    (cond (method
           ;; Invoke Tramp instead of Ange-FTP.
           (apply 'tramp-file-name-handler
                  (cons (tramp-make-tramp-file-name
                         nil (cadr method) user host path)
                        (cdr args))))
           (save-match-data (apply fn args)))
           (ange-ftp-run-real-handler operation args)))))

With the example value for tramp-override-ange-ftp-alist, all
filenames starting with "/address@hidden:" will be handled by Tramp
(using the "sm" method).

However, internally, Tramp still uses the old filenames.  This means
that hitting C-x C-f in a buffer visiting a file via Tramp will still
show "/[sm/address@hidden" (plus some suffix) instead of
"/address@hidden:" (plus some suffix).

The other alternative would be to change Tramp to use a filename
format that's similar to the format used by Ange-FTP and to call
Ange-FTP for some user/host combinations if the method is not
specified.  This would entail removing ange-ftp from
file-name-handler-alist, I guess.  It would also mean that all Tramp
filenames should use the Ange-FTP `style'.

What do you think?

A large number of young women don't trust men with beards.  (BFBS Radio)

reply via email to

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