GNU bug report logs -
#60968
30.0.50; M-x shell keeps an old default-directory
Previous Next
Reported by: Manuel Giraud <manuel <at> ledu-giraud.fr>
Date: Fri, 20 Jan 2023 18:39:01 UTC
Severity: normal
Tags: notabug
Found in version 30.0.50
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 60968 <at> debbugs.gnu.org (full text, mbox):
Manuel Giraud <manuel <at> ledu-giraud.fr> writes:
Hi Manuel,
> Here is an annoyance I bump into sometimes. Recipe:
>
> C-x C-f /-:somewhere-remote:
> M-x shell ;; Emacs asks me about the remote shell and that is not
> ;; what I want
> C-g
> C-x C-f somewhere-local
> M-x shell ;; Emacs still asks me about the previous remote shell
>
> It seems to come from the fact that when in shell.el line 865 the
> "*shell*" buffer is already created and its default-directory set… Or
> maybe, I'm just doing it wrong when I want a shell.
This is the specified behavior of the `shell' command. From the
docstring:
--8<---------------cut here---------------start------------->8---
If BUFFER exists but shell process is not running, make new shell.
If BUFFER exists and shell process is running, just switch to BUFFER.
--8<---------------cut here---------------end--------------->8---
That is, the shell buffer is reused, even if you have interrupted with
C-g, and the shell didn't start yet. And so its default-directory.
If you want another buffer (and another shell therefore), the following
from the docstring is relevant:
--8<---------------cut here---------------start------------->8---
Interactively, a prefix arg means to prompt for BUFFER.
--8<---------------cut here---------------end--------------->8---
So your use case needs "C-u M-x shell". Or you delete the shell buffer
after you have interrupted with C-g.
Best regards, Michael.
This bug report was last modified 2 years and 120 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.