[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name fr
From: |
Stefan Monnier |
Subject: |
Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive` |
Date: |
Sat, 28 May 2022 11:31:04 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Stefan Monnier [2022-05-28 10:12:45] wrote:
>> This misses the `with-connection-local-variables' wrapper in the
>> `interactive' form. Is this intended? It would be a serious regression.
> Oh, I missed that, sorry,
Does the patch below look correct to you?
It also tries to address the FIXME while we're at it.
Stefan
2022-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
* lisp/shell.el (shell): Make sure we set the `default-directory` of
the actual shell buffer after querying the user.
Apply connection-local variables when prompting the user for a remote
shell file-name.
diff --git a/lisp/shell.el b/lisp/shell.el
index 1fcd1a1d1cc..8bcc578406a 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -755,38 +755,47 @@ shell
\(Type \\[describe-mode] in the shell buffer for a list of commands.)"
(interactive
- (list
- (and current-prefix-arg
- (prog1
- (read-buffer "Shell buffer: "
- ;; If the current buffer is an inactive
- ;; shell buffer, use it as the default.
- (if (and (eq major-mode 'shell-mode)
- (null (get-buffer-process (current-buffer))))
- (buffer-name)
- (generate-new-buffer-name "*shell*")))
- (if (file-remote-p default-directory)
- ;; It must be possible to declare a local default-directory.
- ;; FIXME: This can't be right: it changes the default-directory
- ;; of the current-buffer rather than of the *shell* buffer.
- (setq default-directory
- (expand-file-name
- (read-directory-name
- "Default directory: " default-directory default-directory
- t nil))))))
- ;; On remote hosts, the local `shell-file-name' might be useless.
- (when (and (file-remote-p default-directory)
- (null explicit-shell-file-name)
- (null (getenv "ESHELL")))
- ;; `expand-file-name' shall not add the MS Windows volume letter
- ;; (Bug#49229).
- (replace-regexp-in-string
- "^[[:alpha:]]:" ""
- (file-local-name
- (expand-file-name
- (read-file-name "Remote shell path: " default-directory
- shell-file-name t shell-file-name
- #'file-remote-p)))))))
+ (let* ((buffer
+ (and current-prefix-arg
+ (read-buffer "Shell buffer: "
+ ;; If the current buffer is an inactive
+ ;; shell buffer, use it as the default.
+ (if (and (eq major-mode 'shell-mode)
+ (null (get-buffer-process
+ (current-buffer))))
+ (buffer-name)
+ (generate-new-buffer-name "*shell*")))))
+ (buf (if (or buffer (not (derived-mode-p 'shell-mode))
+ (comint-check-proc (current-buffer)))
+ (get-buffer-create (or buffer "*shell*"))
+ ;; If the current buffer is a dead shell buffer, use it.
+ (current-buffer))))
+
+ (with-current-buffer buf
+ (when (and buffer (file-remote-p default-directory))
+ ;; It must be possible to declare a local default-directory.
+ (setq default-directory
+ (expand-file-name
+ (read-directory-name
+ "Default directory: " default-directory default-directory
+ t nil))))
+ (list
+ buffer
+ ;; On remote hosts, the local `shell-file-name' might be useless.
+ (with-connection-local-variables
+ (when (and (file-remote-p default-directory)
+ (null explicit-shell-file-name)
+ (null (getenv "ESHELL")))
+ ;; `expand-file-name' shall not add the MS Windows volume letter
+ ;; (Bug#49229).
+ (replace-regexp-in-string
+ "^[[:alpha:]]:" ""
+ (file-local-name
+ (expand-file-name
+ (read-file-name "Remote shell path: " default-directory
+ shell-file-name t shell-file-name
+ #'file-remote-p))))))))))
+
(setq buffer (if (or buffer (not (derived-mode-p 'shell-mode))
(comint-check-proc (current-buffer)))
(get-buffer-create (or buffer "*shell*"))
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Michael Albinus, 2022/05/28
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Stefan Monnier, 2022/05/28
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`,
Stefan Monnier <=
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Michael Albinus, 2022/05/28
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Stefan Monnier, 2022/05/28
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Michael Albinus, 2022/05/29
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Stefan Monnier, 2022/05/29
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Michael Albinus, 2022/05/29
- Re: master f8b2a01a9e: * lisp/shell.el (shell): Query shell file name from `interactive`, Stefan Monnier, 2022/05/29