emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong default-directory in shell buffer


From: Visuwesh
Subject: Re: Wrong default-directory in shell buffer
Date: Tue, 17 May 2022 15:28:58 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

[திங்கள் மே 16, 2022] Matthias Meulien wrote:

> Matthias Meulien <orontee@gmail.com> writes:
>
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>
>>> Could it be related to "directory tracking", then?
>>
>> I guess so.
>>
>>> There are several different "solutions" to have shell buffers's
>>> `default-directory` track the PWD of the shell, so I'm not sure which
>>> one might be at fault here (if any).
>>
>> I see that shell-dirtrack-verbose is t, and dirtrack-mode is nil. Thus I
>> guess emacs is using the default cd, pushd and popd tracking.
>>
>> I'll study this implementation.
>
> It's simply that when the input is:
>
>   mkdir builddir && cd builddir
>
> the function shell-directory-tracker fails to see the cd command.
>
> I recently develop the habit to call successively:
>
>   mkdir builddir && cd builddir
>   # do some work
>   cd ..
>   rm -rf builddir
>
> repeatedly. If initial value of the default-directory variable is
> /home/matthias/Projets/argos then after 4 iterations it will have been
> updated to /, and with the fifth it will be /..
>
> I observed the same behavior with Emacs 27.1.  No regression!
>
> Comments in shell.el says of directory tracking that: "This is basically
> a fragile hack".  Confirmed.

I have come to the conclusion that the most reliable way to track
directories is to stick the directory in the prompt and parse the prompt
in Emacs side, or if you're on Emacs 28, you can use the OSC7 escape
sequence to track the directory.  I do the latter now, and so far no
problems.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]