[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0d493116aea: Make "toolbox" and "flatpak" multi-hop completion ca
From: |
Michael Albinus |
Subject: |
master 0d493116aea: Make "toolbox" and "flatpak" multi-hop completion capable in Tramp |
Date: |
Sun, 17 Sep 2023 06:13:25 -0400 (EDT) |
branch: master
commit 0d493116aeae3ba21982419d30e6fc12c9117c35
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
Make "toolbox" and "flatpak" multi-hop completion capable in Tramp
* lisp/net/tramp-container.el (tramp-skeleton-completion-function):
Bind `tramp-verbose' to 0.
(tramp-toolbox--completion-function)
(tramp-flatpak--completion-function): Use METHOD as argument.
Use `tramp-skeleton-completion-function'.
(tramp-completion-multi-hop-methods): Add "toolbox" and "flatpak".
---
lisp/net/tramp-container.el | 73 +++++++++++++++++++++++----------------------
1 file changed, 38 insertions(+), 35 deletions(-)
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el
index bef3b04b371..7383ea583cb 100644
--- a/lisp/net/tramp-container.el
+++ b/lisp/net/tramp-container.el
@@ -166,8 +166,10 @@ BODY is the backend specific code."
(or (and (member ,method tramp-completion-multi-hop-methods)
tramp--last-hop-directory)
tramp-compat-temporary-file-directory))
- (program (tramp-get-method-parameter
- (make-tramp-file-name :method ,method)
'tramp-login-program))
+ (program (let ((tramp-verbose 0))
+ (tramp-get-method-parameter
+ (make-tramp-file-name :method ,method)
+ 'tramp-login-program)))
(vec (when (tramp-tramp-file-p default-directory)
(tramp-dissect-file-name default-directory)))
non-essential)
@@ -312,49 +314,48 @@ Obey `tramp-kubernetes-context'"
" "))
;;;###tramp-autoload
-(defun tramp-toolbox--completion-function (&rest _args)
+(defun tramp-toolbox--completion-function (method)
"List Toolbox containers available for connection.
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-toolbox-program " list -c")))
- ;; Ignore header line.
- (lines (cdr (split-string raw-list "\n" 'omit)))
- (names (mapcar
- (lambda (line)
- (when (string-match
- (rx bol (1+ (not space))
- (1+ space) (group (1+ (not space))) space)
- line)
- (match-string 1 line)))
- lines)))
- (mapcar (lambda (name) (list nil name)) (delq nil names))))
+ (tramp-skeleton-completion-function method
+ (when-let ((raw-list (shell-command-to-string (concat program " list -c")))
+ ;; Ignore header line.
+ (lines (cdr (split-string raw-list "\n" 'omit)))
+ (names (mapcar
+ (lambda (line)
+ (when (string-match
+ (rx bol (1+ (not space))
+ (1+ space) (group (1+ (not space))) space)
+ line)
+ (match-string 1 line)))
+ lines)))
+ (mapcar (lambda (name) (list nil name)) (delq nil names)))))
;;;###tramp-autoload
-(defun tramp-flatpak--completion-function (&rest _args)
+(defun tramp-flatpak--completion-function (method)
"List Flatpak sandboxes available for connection.
It returns application IDs or, in case there is no application
ID, instance IDs.
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-flatpak-program
- " ps --columns=instance,application")))
- (lines (split-string raw-list "\n" 'omit))
- (names (mapcar
- (lambda (line)
- (when (string-match
- (rx bol (* space) (group (+ (not space)))
- (? (+ space) (group (+ (not space)))) eol)
- line)
- (or (match-string 2 line) (match-string 1 line))))
- lines)))
- (mapcar (lambda (name) (list nil name)) (delq nil names))))
+ (tramp-skeleton-completion-function method
+ (when-let ((raw-list
+ (shell-command-to-string
+ ;; Ignore header line.
+ (concat program " ps --columns=instance,application | cat -")))
+ (lines (split-string raw-list "\n" 'omit))
+ (names (mapcar
+ (lambda (line)
+ (when (string-match
+ (rx bol (* space) (group (+ (not space)))
+ (? (+ space) (group (+ (not space)))) eol)
+ line)
+ (or (match-string 2 line) (match-string 1 line))))
+ lines)))
+ (mapcar (lambda (name) (list nil name)) (delq nil names)))))
;;;###tramp-autoload
(defvar tramp-default-remote-shell) ;; Silence byte compiler.
@@ -440,15 +441,17 @@ see its function help for a description of the format."
(tramp-set-completion-function
tramp-toolbox-method
- '((tramp-toolbox--completion-function "")))
+ `((tramp-toolbox--completion-function ,tramp-toolbox-method)))
(tramp-set-completion-function
tramp-flatpak-method
- '((tramp-flatpak--completion-function "")))
+ `((tramp-flatpak--completion-function ,tramp-flatpak-method)))
(add-to-list 'tramp-completion-multi-hop-methods tramp-docker-method)
(add-to-list 'tramp-completion-multi-hop-methods tramp-podman-method)
(add-to-list 'tramp-completion-multi-hop-methods tramp-kubernetes-method)
+ (add-to-list 'tramp-completion-multi-hop-methods tramp-toolbox-method)
+ (add-to-list 'tramp-completion-multi-hop-methods tramp-flatpak-method)
;; Default connection-local variables for Tramp.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0d493116aea: Make "toolbox" and "flatpak" multi-hop completion capable in Tramp,
Michael Albinus <=