]> code.delx.au - gnu-emacs-elpa/commitdiff
poptoshell - obtain tramp remote expression if present in shell arg
authorKen Manheimer <ken.manheimer@gmail.com>
Sat, 28 Nov 2015 19:53:57 +0000 (14:53 -0500)
committerKen Manheimer <ken.manheimer@gmail.com>
Sat, 28 Nov 2015 19:53:57 +0000 (14:53 -0500)
Establish the working baseline to build upon.

poptoshell.el

index 12f26d2076c0e75f2dad48e245ae4ed8f23290b9..b9cba193ffbb168bfa716d35a7a07fc3a4f71b00 100644 (file)
@@ -73,14 +73,21 @@ Further,
          (temp (if arg
                    (read-shell-buffer-name-sans
                     (format "Shell buffer name [%s]%s "
-                            pop-to-shell-primary-name
+                            (substring-no-properties
+                             pop-to-shell-primary-name
+                             1 (- (length pop-to-shell-primary-name) 1))
                             (if doublearg " <==" ":"))
                     pop-to-shell-primary-name)
                  pop-to-shell-primary-name))
          ;; Make sure it is bracketed with asterisks; silly.
-         (target-shell-buffer-name (if (string= temp "")
-                                       pop-to-shell-primary-name
-                                     (bracket-asterisks temp)))
+         use-default-dir
+         (target-shell-buffer-name
+          ;; Derive target name, and default-dir if any, from temp.
+          (cond ((string= temp "") pop-to-shell-primary-name)
+                ((string-match "^\\*\\(/.*/\\)\\(.*\\)\\*" temp)
+                 (setq use-default-dir (match-string 1 temp))
+                 (bracket-asterisks (match-string 2 temp)))
+                (t (bracket-asterisks temp))))
          (curr-buff-proc (or (get-buffer-process from)
                              (and (fboundp 'rcirc-buffer-process)
                                   (rcirc-buffer-process))
@@ -94,8 +101,10 @@ Further,
          (inwin nil)
          (num 0)
          already-there)
+
     (when doublearg
       (setq pop-to-shell-primary-name target-shell-buffer-name))
+
     (if (and curr-buff-proc
              (not arg)
              (eq from buff)
@@ -135,6 +144,13 @@ Further,
       (if (not (comint-check-proc (current-buffer)))
           (start-shell-in-buffer (buffer-name (current-buffer))))
       )
+
+    ;; We're in the buffer.
+
+    ;; If we have a use-default-dir, impose it:
+    (when use-default-dir
+        (cd use-default-dir))
+
     ;; If the destination buffer has a stopped process, resume it:
     (let ((process (get-buffer-process (current-buffer))))
       (if (and process (equal 'stop (process-status process)))