]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve Tramp error handling
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 30 May 2024 08:44:30 +0000 (10:44 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 30 May 2024 14:29:17 +0000 (16:29 +0200)
* lisp/net/tramp-container.el (tramp-container-no-container-regexp):
New defcustom.
(tramp-actions-before-shell, tramp-actions-copy-out-of-band): Declare.
Add `tramp-container-no-container-regexp'.  (Bug#71200)

(cherry picked from commit c166abe897bcc2d6e1f59283cf25aef9d47e0c9f)

lisp/net/tramp-container.el

index cc1d9f457cca0a8218fda8b81de4e2527859c079..e456c51045fddcf2cff67952c106483e88c88da9 100644 (file)
 ;;; Code:
 
 (require 'tramp)
+(defvar tramp-actions-before-shell)
+(defvar tramp-actions-copy-out-of-band)
+
+;; This does not match all container-based methods.  Both in general,
+;; the command returns with an error; `tramp-process-alive-regexp'
+;; does the check then.
+(defcustom tramp-container-no-container-regexp
+  (rx bol "Error:" (1+ nonl) "no such container" (0+ nonl)
+      ;; Distrobox adds an interactive prompt.
+      (* "\n" (1+ nonl)))
+  "Regexp matching missing container message.
+The regexp should match at end of buffer."
+  :group 'tramp
+  :version "30.1"
+  :type 'regexp)
 
 ;;;###tramp-autoload
 (defcustom tramp-docker-program "docker"
@@ -620,6 +635,14 @@ see its function help for a description of the format."
   `(:application tramp :protocol ,tramp-kubernetes-method)
   'tramp-kubernetes-connection-local-default-profile))
 
+(add-to-list
+ 'tramp-actions-before-shell
+ '(tramp-container-no-container-regexp tramp-action-permission-denied))
+
+(add-to-list
+ 'tramp-actions-copy-out-of-band
+ '(tramp-container-no-container-regexp tramp-action-permission-denied))
+
 ;;;###tramp-autoload
 (defun tramp-enable-toolbox-method ()
   "Enable connection to Toolbox containers."