]> code.delx.au - gnu-emacs-elpa/commitdiff
poptoshell - cleanup lapsed remote connections before restarting them
authorKen Manheimer <ken.manheimer@gmail.com>
Fri, 1 Jan 2016 17:07:25 +0000 (12:07 -0500)
committerKen Manheimer <ken.manheimer@gmail.com>
Fri, 1 Jan 2016 17:21:02 +0000 (12:21 -0500)
Woo hoo! This seems to be vastly improving the resurrection of lapsed
connections, preventing the frequent (and uncatchable) "byte-code: Args
out of range: ..." errors. So far, completely.

poptoshell.el

index b0204600bea4799f0a8506bfae698d0a5edc64dc..39d741a0d8f6294bc85f0cd7742573b1f47e266a 100644 (file)
@@ -265,6 +265,15 @@ on empty input."
          (name (file-name-nondirectory prog))
          (startfile (concat "~/.emacs_" name))
          (xargs-name (intern-soft (concat "explicit-" name "-args"))))
+    (set-buffer buffer-name)
+    (when (and (file-remote-p default-directory)
+               (eq major-mode 'shell-mode)
+               (not (comint-check-proc (current-buffer))))
+      ;; We're returning to an already established but disconnected remote
+      ;; shell, tidy it:
+      (tramp-cleanup-connection
+       (tramp-dissect-file-name default-directory 'noexpand)
+       'keep-debug 'keep-password))
     (setq buffer (set-buffer (apply 'make-comint
                                     (unbracket-asterisks buffer-name)
                                     prog
@@ -274,13 +283,6 @@ on empty input."
                                              (boundp xargs-name))
                                         (symbol-value xargs-name)
                                       '("-i")))))
-    (set-buffer buffer-name)
-    (shell-mode)
-    (when (and (file-remote-p default-directory)
-             (not (comint-check-proc (current-buffer))))
-      (message "(Re)connection failed, doing a cleanup then retry...")
-      (sit-for 0)
-      (tramp-cleanup-this-connection)
-      (shell-mode))))
+    (shell-mode)))
 
 (provide 'poptoshell)