mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
* lisp/shell.el (shell): Fix last change
Wrap the file-name prompt within `with-connection-local-variables` as it was before the previous change. While at it, make sure we set the `default-directory` of the actual shell buffer after querying the user.
This commit is contained in:
parent
e1eab9b496
commit
aa955dc569
@ -755,38 +755,47 @@ Make the shell buffer the current buffer, and return it.
|
||||
|
||||
\(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*"))
|
||||
|
Loading…
Reference in New Issue
Block a user