]> code.delx.au - gnu-emacs-elpa/blobdiff - multishell.el
multishell - don't swallow connection errors besides tramp homedir prob
[gnu-emacs-elpa] / multishell.el
index ea8958e5eecfaed4d12be8ef5b388b61ba435768..7295aa1ea904dc60eb71e57fc0367aade177db51 100644 (file)
@@ -93,6 +93,8 @@
 (require 'comint)
 (require 'shell)
 
+(defvar multishell-version "1.0.5")
+
 (defgroup multishell nil
   "Allout extension that highlights outline structure graphically.
 
@@ -183,20 +185,19 @@ emacs sessions."
 (defun multishell-register-name-to-path (name path)
   "Add or replace entry associating NAME with PATH in `multishell-history'.
 
-If NAME already had a PATH and new PATH is empty, retain old one.
+If NAME already had a PATH and new PATH is empty, retain the prior one.
 
 Promote added/changed entry to the front of the list."
   ;; Add or promote to the front, tracking path changes in the process.
   (let* ((entries (multishell-history-entries name))
-         (becomes (concat name path))
-         oldpath)
+         (path (or path "")))
     (dolist (entry entries)
-      (when (or (not path) (string= path ""))
+      (when (string= path "")
         ;; Retain explicit established path.
-        (setq path (cadr (multishell-split-entry-name-and-tramp entry))
-              becomes (concat name path)))
+        (setq path (cadr (multishell-split-entry-name-and-tramp entry))))
       (setq multishell-history (delete entry multishell-history)))
-    (setq multishell-history (push becomes multishell-history))))
+    (setq multishell-history (push (concat name path)
+                                   multishell-history))))
 
 (defun multishell-history-entries (name)
   "Return `multishell-history' entry that starts with NAME, or nil if none."
@@ -318,14 +319,15 @@ customize the savehist group to activate savehist."
          (curr-buff-proc (get-buffer-process from-buffer))
          (target-buffer (if from-buffer-is-shell
                             from-buffer
-                          (let ((got (get-buffer target-shell-buffer-name)))
-                            (if (buffer-live-p got)
-                                got
-                              (kill-buffer got)
-                              (get-buffer target-shell-buffer-name)))))
+                          (get-buffer target-shell-buffer-name)))
          inwin
          already-there)
 
+    ;; Register early so the entry is pushed to the front:
+    (multishell-register-name-to-path (multishell-unbracket-asterisks
+                                       target-shell-buffer-name)
+                                      use-default-dir)
+
     (when doublearg
       (setq multishell-primary-name target-shell-buffer-name))
 
@@ -370,9 +372,7 @@ customize the savehist group to activate savehist."
     (let ((process (get-buffer-process (current-buffer))))
       (if (and process (equal 'stop (process-status process)))
           (continue-process process)))
-    (multishell-register-name-to-path (multishell-unbracket-asterisks
-                                       target-shell-buffer-name)
-                                      use-default-dir)
+
     (when (or already-there
              (equal (current-buffer) from-buffer))
       (goto-char (point-max))
@@ -535,15 +535,16 @@ Return them as a list (name dir), with dir nil if none given."
         (cd default-directory)
       (error
        ;; Aargh. Need to isolate this tramp bug.
-       (when (and (stringp (cadr err))
-                  (string-equal (cadr err)
-                                "Selecting deleted buffer"))
-         (signal (car err)
-                 (list
-                  (format "%s, %s (\"%s\")"
-                          "Tramp shell can fail on empty (homedir) path"
-                          "please try again with an explicit path"
-                          (cadr err)))))))
+       (if (and (stringp (cadr err))
+                (string-equal (cadr err)
+                              "Selecting deleted buffer"))
+           (signal (car err)
+                   (list
+                    (format "%s, %s (\"%s\")"
+                            "Tramp shell can fail on empty (homedir) path"
+                            "please try again with an explicit path"
+                            (cadr err))))
+         (signal (car err)(cdr err)))))
     (setq buffer (set-buffer (apply 'make-comint
                                     (multishell-unbracket-asterisks buffer-name)
                                     prog