[Top][All Lists]

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

Re: Tramp mosh method

From: Michael Albinus
Subject: Re: Tramp mosh method
Date: Mon, 19 Nov 2012 20:50:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Ted Zlatanov <address@hidden> writes:

Hi Ted,

> Have you documented how to write a new Tramp method?  I remember with
> tramp-imap.el it was quite a struggle for me.  That being said, I would
> love to learn Tramp as a long-term project.

Unfortunately, it's not documented in detail. There's just the usual
"read an example, like tramp-smb.el". However, in the mosh case it
wouldn't be such terrible, because we can use most of tramp-sh.el

> Let's not restrict it to new Emacsen.  I'd rather use
> `tramp-process-filter' and support older Emacsen.  It sounds like a
> fairly simple refactoring, actually.

Well, I wouldn't care too much about backward compatibility for the mosh
method. But you are right, it doesn't sound too hard to keep it.

> MA> If we use the latter approach (`add-function'), we would be able to fix
> MA> such errors in Emacs' trunk. Somehow, I hate code duplication ...
> Me too, but this is not duplicating code.  Those filters have a very
> specific need and target interactive usage.  We're trying to clean
> everything out of the text stream.  I suspect our code will be much
> simpler if we don't try to coexist with other filters but simply clear
> all escape sequences.

OK. Just some rough ideas how to start. We don't need new handlers for
doing all actions once the connection is established, all of this can be
performed by the tramp-sh handlers. Just the connection establishing is
a bit tricky.

We might add a new buffer local variable `tramp-process-filter-hook' and
a new function `tramp-process-filter'. This function is set as process
filter in `tramp-maybe-open-connection'. It runs all functions of
`tramp-process-filter-hook'; those functions have the same arguments as
any process filter.

We should add a new optional property `tramp-process-filter' for the
methods in `tramp-methods'. When set for a given method, that function
is added to `tramp-process-filter-hook' in `tramp-maybe-open-connection'.

Furthermore, `comint-output-filter' might be added to
`tramp-process-filter-hook' in `tramp-handle-shell-command'. Other
settings could be added later, if the process filter machinery works.

Now we need a new package tramp-mosh.el. It declares the mosh method
like the ssh method, plus the process filter:

(add-to-list 'tramp-methods
    (tramp-login-program        "mosh")
    (tramp-login-args           ...)
    (tramp-async-args           ...)
    (tramp-process-filter       'tramp-mosh-process-filter)
    (tramp-remote-shell         "/bin/sh")
    (tramp-remote-shell-args    ("-c"))
    (tramp-default-port         22)))

(add-to-list 'tramp-foreign-file-name-handler-alist
             (cons 'tramp-mosh-file-name-p 'tramp-sh-file-name-handler))

`tramp-mosh-method' and `tramp-mosh-file-name-p' shall be simple to
write. There are also some other settings, for example for file name
completion, you will see. The heart of tramp-mosh.el will be

Roughly, that's the plan. Plus all the things I've forgotten to
tell. You will ask :-)

> Ted

Best regards, Michael.

reply via email to

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