[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e2b37f901d1: Fix host name completion for Tramp "podman" method
|
From: |
Michael Albinus |
|
Subject: |
master e2b37f901d1: Fix host name completion for Tramp "podman" method |
|
Date: |
Sun, 29 Jan 2023 04:33:55 -0500 (EST) |
branch: master
commit e2b37f901d16d8e621d2adfed84f46a21a3716ab
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
Fix host name completion for Tramp "podman" method
* lisp/net/tramp-container.el (tramp-container--completion-function):
Rename from `tramp-docker--completion-function'. Add argument
PROGRAM. Use it for "docker" and "podman" host name completion.
* lisp/net/tramp.el (tramp-set-completion-function): Check, that
cdr of FUNCTION-LIST entries is a string.
---
lisp/net/tramp-container.el | 23 ++++++++++++-----------
lisp/net/tramp.el | 3 ++-
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el
index 1dd29190f10..5ae9ebaefb2 100644
--- a/lisp/net/tramp-container.el
+++ b/lisp/net/tramp-container.el
@@ -121,15 +121,16 @@
"Tramp method name to use to connect to Toolbox containers.")
;;;###tramp-autoload
-(defun tramp-docker--completion-function (&rest _args)
- "List Docker-like containers available for connection.
+(defun tramp-container--completion-function (program)
+ "List running containers available for connection.
+PROGRAM is the program to be run for \"ps\", either
+`tramp-docker-program' or `tramp-podman-program'.
This function is used by `tramp-set-completion-function', please
see its function help for a description of the format."
(when-let ((default-directory tramp-compat-temporary-file-directory)
(raw-list (shell-command-to-string
- (concat tramp-docker-program
- " ps --format '{{.ID}}\t{{.Names}}'")))
+ (concat program " ps --format '{{.ID}}\t{{.Names}}'")))
(lines (split-string raw-list "\n" 'omit))
(names (mapcar
(lambda (line)
@@ -139,7 +140,7 @@ see its function help for a description of the format."
line)
(or (match-string 2 line) (match-string 1 line))))
lines)))
- (mapcar (lambda (m) (list nil m)) (delq nil names))))
+ (mapcar (lambda (name) (list nil name)) (delq nil names))))
;;;###tramp-autoload
(defun tramp-kubernetes--completion-function (&rest _args)
@@ -153,9 +154,7 @@ see its function help for a description of the format."
" get pods --no-headers "
"-o custom-columns=NAME:.metadata.name")))
(names (split-string raw-list "\n" 'omit)))
- (mapcar (lambda (name)
- (list nil name))
- names)))
+ (mapcar (lambda (name) (list nil name)) (delq nil names))))
(defun tramp-kubernetes--current-context-data (vec)
"Return Kubernetes current context data as JSON string."
@@ -194,7 +193,7 @@ see its function help for a description of the format."
line)
(match-string 1 line)))
lines)))
- (mapcar (lambda (m) (list nil m)) (delq nil names))))
+ (mapcar (lambda (name) (list nil name)) (delq nil names))))
;;;###tramp-autoload
(defvar tramp-default-remote-shell) ;; Silence byte compiler.
@@ -256,11 +255,13 @@ see its function help for a description of the format."
(tramp-set-completion-function
tramp-docker-method
- '((tramp-docker--completion-function "")))
+ `((tramp-container--completion-function
+ ,(executable-find tramp-docker-program))))
(tramp-set-completion-function
tramp-podman-method
- '((tramp-docker--completion-function "")))
+ `((tramp-container--completion-function
+ ,(executable-find tramp-podman-program))))
(tramp-set-completion-function
tramp-kubernetes-method
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 50e1e2479d5..3871ee4dddd 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2458,13 +2458,14 @@ Example:
(setcdr v (delete (car v) (cdr v))))
;; Check for function and file or registry key.
(unless (and (functionp (nth 0 (car v)))
+ (stringp (nth 1 (car v)))
(cond
;; Windows registry.
((string-prefix-p "HKEY_CURRENT_USER" (nth 1 (car v)))
(and (memq system-type '(cygwin windows-nt))
(zerop
(tramp-call-process
- v "reg" nil nil nil "query" (nth 1 (car v))))))
+ nil "reg" nil nil nil "query" (nth 1 (car v))))))
;; DNS-SD service type.
((string-match-p
tramp-dns-sd-service-regexp (nth 1 (car v))))
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- master e2b37f901d1: Fix host name completion for Tramp "podman" method,
Michael Albinus <=