aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2024-05-31 16:27:47 +0200
committerMichael Albinus2024-05-31 16:27:47 +0200
commit0cb511b33bc96fc30d8e5286a474b4eea54817e3 (patch)
tree5fc37b0a8c027da7d61c4f0f433733c396ccae92
parent319e16550d665d1eae6f9e355c475ab668371cf3 (diff)
downloademacs-0cb511b33bc96fc30d8e5286a474b4eea54817e3.tar.gz
emacs-0cb511b33bc96fc30d8e5286a474b4eea54817e3.zip
Make Tramp error handling more precise
* lisp/net/tramp-container.el (tramp-actions-copy-out-of-band) (tramp-container-no-container-regexp): Remove. Do not register them. (tramp-distrobox-no-container-regexp): New defcustom. (tramp-enable-distrobox-method): Add it to `'tramp-actions-before-shell. (Bug#71200)
-rw-r--r--lisp/net/tramp-container.el37
1 files changed, 14 insertions, 23 deletions
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el
index e456c51045f..278ce033da6 100644
--- a/lisp/net/tramp-container.el
+++ b/lisp/net/tramp-container.el
@@ -118,20 +118,6 @@
118 118
119(require 'tramp) 119(require 'tramp)
120(defvar tramp-actions-before-shell) 120(defvar tramp-actions-before-shell)
121(defvar tramp-actions-copy-out-of-band)
122
123;; This does not match all container-based methods. Both in general,
124;; the command returns with an error; `tramp-process-alive-regexp'
125;; does the check then.
126(defcustom tramp-container-no-container-regexp
127 (rx bol "Error:" (1+ nonl) "no such container" (0+ nonl)
128 ;; Distrobox adds an interactive prompt.
129 (* "\n" (1+ nonl)))
130 "Regexp matching missing container message.
131The regexp should match at end of buffer."
132 :group 'tramp
133 :version "30.1"
134 :type 'regexp)
135 121
136;;;###tramp-autoload 122;;;###tramp-autoload
137(defcustom tramp-docker-program "docker" 123(defcustom tramp-docker-program "docker"
@@ -252,6 +238,15 @@ This is for out-of-band connections.")
252(defconst tramp-nspawn-method "nspawn" 238(defconst tramp-nspawn-method "nspawn"
253 "Tramp method name to connect to systemd-nspawn containers.") 239 "Tramp method name to connect to systemd-nspawn containers.")
254 240
241(defcustom tramp-distrobox-no-container-regexp
242 (rx bol "Error:" (1+ nonl) "no such container" (0+ nonl) "\n"
243 "Create it now, out of image " (+ (not blank)) "? [Y/n]:" (* blank))
244 "Regexp matching missing distrobox error message.
245The regexp should match at end of buffer."
246 :group 'tramp
247 :version "30.1"
248 :type 'regexp)
249
255;;;###tramp-autoload 250;;;###tramp-autoload
256(defmacro tramp-skeleton-completion-function (method &rest body) 251(defmacro tramp-skeleton-completion-function (method &rest body)
257 "Skeleton for `tramp-*-completion-function' with multi-hop support. 252 "Skeleton for `tramp-*-completion-function' with multi-hop support.
@@ -635,14 +630,6 @@ see its function help for a description of the format."
635 `(:application tramp :protocol ,tramp-kubernetes-method) 630 `(:application tramp :protocol ,tramp-kubernetes-method)
636 'tramp-kubernetes-connection-local-default-profile)) 631 'tramp-kubernetes-connection-local-default-profile))
637 632
638(add-to-list
639 'tramp-actions-before-shell
640 '(tramp-container-no-container-regexp tramp-action-permission-denied))
641
642(add-to-list
643 'tramp-actions-copy-out-of-band
644 '(tramp-container-no-container-regexp tramp-action-permission-denied))
645
646;;;###tramp-autoload 633;;;###tramp-autoload
647(defun tramp-enable-toolbox-method () 634(defun tramp-enable-toolbox-method ()
648 "Enable connection to Toolbox containers." 635 "Enable connection to Toolbox containers."
@@ -682,7 +669,11 @@ see its function help for a description of the format."
682 669
683 (tramp-set-completion-function 670 (tramp-set-completion-function
684 tramp-distrobox-method 671 tramp-distrobox-method
685 `((tramp-distrobox--completion-function ,tramp-distrobox-method)))) 672 `((tramp-distrobox--completion-function ,tramp-distrobox-method)))
673
674 (add-to-list
675 'tramp-actions-before-shell
676 '(tramp-distrobox-no-container-regexp tramp-action-permission-denied)))
686 677
687;;;###tramp-autoload 678;;;###tramp-autoload
688(defun tramp-enable-flatpak-method () 679(defun tramp-enable-flatpak-method ()