[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to autoload Tramp methods
From: |
Michael Albinus |
Subject: |
Re: How to autoload Tramp methods |
Date: |
Tue, 08 Oct 2024 13:09:46 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Eshel Yaron <me@eshelyaron.com> writes:
> Hi,
Hi Eshel,
> One option that comes to mind is something like:
>
> diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
> index 8961b872a8a..a82a3e564d8 100644
> --- a/lisp/net/tramp.el
> +++ b/lisp/net/tramp.el
> @@ -1794,7 +1794,12 @@ tramp-dissect-file-name
> :port port :localname localname :hop hop))
> ;; The method must be known.
> (unless (or nodefault non-essential
> - (assoc method tramp-methods))
> + (assoc method tramp-methods)
> + (when-let ((enable-fun
> + (intern-soft
> + (format "tramp-enable-%s-method" method)))
> + ((functionp enable-fun)))
> + (funcall enable-fun)))
> (tramp-user-error
> v "Method `%s' is not known" method))
> ;; Only some methods from tramp-sh.el do support multi-hops.
>
> Then in foo-tramp I could define tramp-enable-foo-method, have it return
> non-nil, give it an autoload cookie, and that's it. How would you feel
> about such an approach?
The idea is good. However, tramp-dissect-file-name is the most often
calles function in Tramp (a workhorse), I wouldn't like to make it
heavier.
How about defining and autoloading tramp-enable-foo-method, and *also*
adding in foo-tramp.el
--8<---------------cut here---------------start------------->8---
;;;###autoload
(tramp-enable-method "foo")
--8<---------------cut here---------------end--------------->8---
In order to avoid loading foo-tramp due to this call, you must autoload
the *implementation* of tramp-enable-foo-method, like
--8<---------------cut here---------------start------------->8---
;;;###autoload
(progn (defun tramp-enable-foo-method ()
"Enable connection to foo."
(add-to-list 'tramp-methods
`("foo"
...))))
--8<---------------cut here---------------end--------------->8---
> Best regards,
>
> Eshel
Best regards, Michael.
- How to autoload Tramp methods, Eshel Yaron, 2024/10/05
- Re: How to autoload Tramp methods, Michael Albinus, 2024/10/08
- Re: How to autoload Tramp methods, Eshel Yaron, 2024/10/08
- Re: How to autoload Tramp methods,
Michael Albinus <=
- Re: How to autoload Tramp methods, Eshel Yaron, 2024/10/08
- Re: How to autoload Tramp methods, Michael Albinus, 2024/10/08
- Re: How to autoload Tramp methods, Eshel Yaron, 2024/10/08
- Re: How to autoload Tramp methods, Michael Albinus, 2024/10/08
- Re: How to autoload Tramp methods, Eshel Yaron, 2024/10/09
- Re: How to autoload Tramp methods, Michael Albinus, 2024/10/09