]> git.eshelyaron.com Git - emacs.git/commitdiff
(tramp-enable-method): Add minibuffer action
authorEshel Yaron <me@eshelyaron.com>
Wed, 8 May 2024 17:10:56 +0000 (19:10 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 8 May 2024 17:10:56 +0000 (19:10 +0200)
lisp/net/tramp-sh.el
lisp/net/tramp.el

index bb136d6e6b5ff6f9e2dd39ee8dcf4b6ad60ae9bd..4347bf93ac25fa778c9efbe39329048cdc914d25 100644 (file)
@@ -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")
index f2f25e60cc29afefc844de5bf2cd820afad9f631..c0c83464ee80bda843323cdb165c22e369abdbd6 100644 (file)
@@ -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.