From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.devel Subject: Re: Wrong default-directory in shell buffer Date: Tue, 17 May 2022 15:28:58 +0530 Message-ID: <87wnekfpjx.fsf@gmail.com> References: <874k1vzyom.fsf@posteo.net> <87lev2j3g0.fsf_-_@gmail.com> <87h75pic7h.fsf@gmail.com> <875ym5i8cz.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20215"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Stefan Monnier , emacs-devel@gnu.org To: Matthias Meulien Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 17 13:51:39 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqvjn-00051r-0Q for ged-emacs-devel@m.gmane-mx.org; Tue, 17 May 2022 13:51:39 +0200 Original-Received: from localhost ([::1]:57142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqvjl-00060U-C9 for ged-emacs-devel@m.gmane-mx.org; Tue, 17 May 2022 07:51:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqtys-0007Mn-41 for emacs-devel@gnu.org; Tue, 17 May 2022 05:59:06 -0400 Original-Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:34509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nqtyp-0000im-KB for emacs-devel@gnu.org; Tue, 17 May 2022 05:59:05 -0400 Original-Received: by mail-pg1-x544.google.com with SMTP id g184so16518001pgc.1 for ; Tue, 17 May 2022 02:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=kYz3vjiGfJF0W8JGn1Xmo/EBEQZKdcZQurWI8+Ve4sI=; b=nrH//5GeH9KbLZGe4vVUFGpLjGeThNXMv2zmS1Lam3YuoXOpKO/xJ1DFz8B1NPpvhM uTv7oqBpg32ji1MYwxW6PX1zYEVdC4Oc8R+P7VMI/KX6BRix+rgGJzT4NoQSFbbTj1bw mNb/p24JLaN/IEZg9CF+wRnVCm6xi80qJmHq+6ZlZ9WsmgIXcJ/pS5HpPCBFEQEX6qUd 4q0yRr2+1IHMsAnWAT1iD0WcdI5TiyI/p0f/1+0NTxzocp5ySfskFSRoAo7aANM0M8ZJ mzusLZdaeu6s+TMd3KWSEZYBu+4x0UNBGxq0QMfKwfIo0JOdwGHiy1st3du8Eti82GYK Wmng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:mail-followup-to :date:in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=kYz3vjiGfJF0W8JGn1Xmo/EBEQZKdcZQurWI8+Ve4sI=; b=CR+PD6L/q2Q01ZKpjOahyoW8FAxznAbVH+dvskq5F0keaH0o0T0iMm9ELn8sE9tLMo zFPvyR/PUWblPrKl8dVT86X2cT8SDo3IzmTOROtlidi7Ljs3qRuwCKq+tYYMJV1XZAmU OEC/NMDE5DUxTrV4WT9ok6brEGNYQ+ac8/EufSWmWs3tPX4s+NGylpPP/2h23RC5zMlP +0z4BiSB7c6ADTX494myrSsbhjIEVtymdw3mGN6ouWYC5VVNU2ucTjsLjsK3Dd4mvMSZ 2twGd6YIOuyQ+EX6qBO4MI7Z7mSgl1zak3oMafRcUfj75rRfSKJhJbuswN2NRdivblcF TesA== X-Gm-Message-State: AOAM531pBPGYjeyxiHxrmB/u2WK0K33IDKkrJ9Ma8gzXIGFc9B+vWlfo aDuhKPgVDaglABSqYNo5WuE= X-Google-Smtp-Source: ABdhPJy3W6x0FIlpFduUzGsB3er/DtewVwQtJsC+DFIu41omS7tGDUu8Bx0uppSwiXGTO84aS89Kgw== X-Received: by 2002:a63:9141:0:b0:3c6:270f:cec2 with SMTP id l62-20020a639141000000b003c6270fcec2mr18266687pge.182.1652781542067; Tue, 17 May 2022 02:59:02 -0700 (PDT) Original-Received: from localhost ([49.205.81.115]) by smtp.gmail.com with ESMTPSA id n2-20020a635c42000000b003c14af50615sm6363472pgm.45.2022.05.17.02.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 02:59:01 -0700 (PDT) Mail-Followup-To: Matthias Meulien , Stefan Monnier , emacs-devel@gnu.org In-Reply-To: <875ym5i8cz.fsf@gmail.com> (Matthias Meulien's message of "Mon, 16 May 2022 21:29:48 +0200") Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=visuweshm@gmail.com; helo=mail-pg1-x544.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 17 May 2022 07:40:52 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289841 Archived-At: [=E0=AE=A4=E0=AE=BF=E0=AE=99=E0=AF=8D=E0=AE=95=E0=AE=B3=E0=AF=8D =E0=AE=AE= =E0=AF=87 16, 2022] Matthias Meulien wrote: > Matthias Meulien writes: > >> Stefan Monnier 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.