From f0637731bb6e118313d061c0701d751193856f34 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 8 May 2024 19:10:56 +0200 Subject: [PATCH] (tramp-enable-method): Add minibuffer action --- lisp/net/tramp-sh.el | 2 +- lisp/net/tramp.el | 36 +++++++++++++++++------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index bb136d6e6b5..4347bf93ac2 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -477,7 +477,7 @@ The string is used in `tramp-methods'.") ;;;###tramp-autoload (defun tramp-enable-nc-method () - "Enable \"ksu\" method." + "Enable \"nc\" method." (add-to-list 'tramp-methods `("nc" (tramp-login-program "telnet") diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f2f25e60cc2..c0c83464ee8 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1464,31 +1464,29 @@ calling HANDLER.") "Enable optional METHOD if possible." (interactive (list - (completing-read - "method: " - (seq-keep - (lambda (x) - (when-let ((name (symbol-name x)) - ;; It must match `tramp-enable-METHOD-method'. - ((string-match - (rx "tramp-enable-" - (group (regexp tramp-method-regexp)) - "-method") - name)) - (method (match-string 1 name)) - ;; It must not be enabled yet. - ((not (assoc method tramp-methods)))) - method)) - ;; All method enabling functions. - (mapcar - #'intern (all-completions "tramp-enable-" obarray #'functionp)))))) - + (let ((methods nil)) + (mapatoms (lambda (sym) + (when-let ((fboundp sym) + (name (symbol-name sym)) + ;; It must match `tramp-enable-METHOD-method'. + ((string-match + (rx "tramp-enable-" + (group (regexp tramp-method-regexp)) + "-method") + name)) + (method (match-string 1 name))) + (push method methods)))) + (completing-read "Enable Tramp method: " methods + (lambda (method) + (not (assoc method tramp-methods))))))) (when-let (((not (assoc method tramp-methods))) (fn (intern (format "tramp-enable-%s-method" method))) ((functionp fn))) (funcall fn) (message "Tramp method \"%s\" enabled" method))) +(put 'tramp-enable-method 'minibuffer-action "enable") + ;; Conversion functions between external representation and ;; internal data structure. Convenience functions for internal ;; data structure. -- 2.39.5