[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/multishell b314574 01/23: multishell-start-shell-in-buf
From: |
Stefan Monnier |
Subject: |
[elpa] externals/multishell b314574 01/23: multishell-start-shell-in-buffer: be tolerant of absent remote dirs.xo |
Date: |
Sun, 29 Nov 2020 23:19:35 -0500 (EST) |
branch: externals/multishell
commit b314574252f9c42833c48ad822b31ce51e01bc20
Author: Ken Manheimer <ken.manheimer@gmail.com>
Commit: Ken Manheimer <ken.manheimer@gmail.com>
multishell-start-shell-in-buffer: be tolerant of absent remote dirs.xo
If cd fails to an included remote directory, try again without the cd.
---
multishell.el | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/multishell.el b/multishell.el
index 51bad08..23da6ae 100644
--- a/multishell.el
+++ b/multishell.el
@@ -694,7 +694,11 @@ and path nil if none is resolved."
(declare-function tramp-cleanup-connection "tramp")
(defun multishell-start-shell-in-buffer (path)
- "Start, restart, or continue a shell in BUFFER-NAME on PATH."
+ "Start, restart, or continue a shell in BUFFER-NAME on PATH.
+
+If the path is remote and includes a directory, cd to that directory on the
remote path.
+
+If cd fails to an included remote directory, try again without the cd."
(let* ((is-active (comint-check-proc (current-buffer))))
(when (and path (not is-active))
@@ -710,8 +714,25 @@ and path nil if none is resolved."
(tramp-dissect-file-name default-directory 'noexpand)
'keep-debug 'keep-password))
- (when (file-remote-p path) (message "Connecting to %s" path))
- (cd path))
+ (if (not (file-remote-p path))
+ (cd path)
+ (message "Connecting to %s" path)
+ (condition-case err
+ (cd path)
+ ;; "cd: No such directory found via CDPATH environment variable"
+ (error
+ (if (string=
+ (cadr err)
+ "No such directory found via CDPATH environment variable")
+ ;; Try again without dir part of remote path:
+ (let* ((final-colon-at (string-match ":[^:]+$" path))
+ (sans-dir-path (substring path 0 (1+ final-colon-at)))
+ (dir-path (substring path (1+ final-colon-at))))
+ (message "Failed to cd to %s, trying again without..."
+ dir-path)
+ (sit-for .5)
+ (cd sans-dir-path))
+ (signal (car err) (cdr err)))))))
(shell (current-buffer))))
- [elpa] branch externals/multishell created (now 35a0dd3), Stefan Monnier, 2020/11/29
- [elpa] externals/multishell b314574 01/23: multishell-start-shell-in-buffer: be tolerant of absent remote dirs.xo,
Stefan Monnier <=
- [elpa] externals/multishell 6d77e93 02/23: Increment version number., Stefan Monnier, 2020/11/29
- [elpa] externals/multishell 708bad6 03/23: Forward compatibility: cl-progv rather than progv, Stefan Monnier, 2020/11/29
- [elpa] externals/multishell c39be89 04/23: Increment version to 1.1.7 and copyright span to include current year., Stefan Monnier, 2020/11/29
- [elpa] externals/multishell bf8c445 05/23: Use appropriate interactive mode., Stefan Monnier, 2020/11/29
- [elpa] externals/multishell ee12b22 08/23: Unravel conditional tangle (and use bound-and-true-p), Stefan Monnier, 2020/11/29
- [elpa] externals/multishell 6b0bc33 12/23: Rectify code formatting, per gnu people's guidance., Stefan Monnier, 2020/11/29
- [elpa] externals/multishell aae3f1e 06/23: Use dolist instead of mapcar., Stefan Monnier, 2020/11/29
- [elpa] externals/multishell 5adbb49 09/23: Remove unused variable., Stefan Monnier, 2020/11/29
- [elpa] externals/multishell 2b4d9d7 15/23: Rectify code formatting, per gnu people's guidance., Stefan Monnier, 2020/11/29
- [elpa] externals/multishell 0d349ee 16/23: Revise in-file change log acknowledging other's work and prior unreleased, Stefan Monnier, 2020/11/29