unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Allen Li <darkfeline@felesatra.moe>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 66903@debbugs.gnu.org
Subject: bug#66903: 29.1; shell-mode directory tracking incorrectly handles double slashes
Date: Fri, 3 Nov 2023 13:54:09 -0700	[thread overview]
Message-ID: <CADbSrJwt3dS8OoM8TUaYtDvcbApvSby7wKr7dU2S9taFPduv=g@mail.gmail.com> (raw)
In-Reply-To: <83cywr6nvx.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2605 bytes --]

On Fri, Nov 3, 2023 at 5:07 AM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Allen Li <darkfeline@felesatra.moe>
> > Date: Fri, 3 Nov 2023 03:43:35 -0700
> > Cc: 66903@debbugs.gnu.org
> >
> > Currently, `cd ~//bin` will cause the shell (Bash or similar) to change
> to ~/bin, and Emacs/shell-mode
> > will change `default-directory` to `/bin`.
> >
> > This bug is saying that Emacs/shell-mode should change
> `default-directory` to `~/bin` by default,
>
> I think it should change default-directory to the directory to which
> the shell switches, not necessarily ~/bin.
>

That sounds different from what you're implying in your other emails.
Using sentences here is confusing.

The current behavior is:

Case 1
input: ~//bin
shell: ~/bin
default-directory: /bin

I'm suggesting

Case 2
input: ~//bin
shell: ~/bin
default-directory: ~/bin

When you say "I think it should change default-directory to the directory
to which
the shell switches, not necessarily ~/bin.", that implies to me Case 2

But your other emails suggest that you want:

Case 3
input: ~//bin (Emacs rewrites to /bin before sending to shell)
shell: /bin
default-directory: /bin

Assuming that you want Case 3, I think that is horrible for multiple
reasons.  Firstly, a user would expect their shell to behave as in Case 2;
Case 3 is a surprising and semantically different rewrite of user input.
Furthermore, we would either have to rewrite all paths not just paths to
`cd`, which would be infeasible and error-prone, or surprise the user again
that Emacs is rewriting paths to `cd` specifically, but not, say, `rm` or
`mv` or many other commands (e.g., `mv ~//bin ~//lib`).  Furthermore, the
only shell input rewriting that Emacs currently does is for history
substitutions, and the syntax for this is identical to common shells;
therefore, users can expect that Emacs does not do any surprising semantic
rewrites of their shell input.  Case 3 would be violating this expectation.

For completeness, there is also

Case 4
input: ~//bin
shell: /bin (normal shell behavior)
default-directory: /bin

However, I am aware of zero shells in common use that behave like Case 4.
Even if we consider it, it should not be the default.

Also for completeness, there is a nuclear solution option, which is to
replace all of the cd, pushd, popd logic that shell-mode currently
implements and always run M-x dirs after every cd, pushd, popd command.
This naturally results in the behavior of Case 2, but also supports Case 4
for hypothetical shells that have said behavior.

[-- Attachment #2: Type: text/html, Size: 3581 bytes --]

  reply	other threads:[~2023-11-03 20:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03  0:14 bug#66903: 29.1; shell-mode directory tracking incorrectly handles double slashes Allen Li
2023-11-03  7:15 ` Eli Zaretskii
2023-11-03  7:22   ` Allen Li
2023-11-03  7:26     ` Eli Zaretskii
2023-11-03  8:35       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-03 12:02         ` Eli Zaretskii
2023-11-03 12:35           ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-03 14:24             ` Eli Zaretskii
2023-11-04  0:21               ` Stefan Kangas
2023-11-04  2:53                 ` Visuwesh
2023-11-03 10:43       ` Allen Li
2023-11-03 12:07         ` Eli Zaretskii
2023-11-03 20:54           ` Allen Li [this message]
2023-11-04  6:34             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADbSrJwt3dS8OoM8TUaYtDvcbApvSby7wKr7dU2S9taFPduv=g@mail.gmail.com' \
    --to=darkfeline@felesatra.moe \
    --cc=66903@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).