zsh-workers
 help / color / mirror / code / Atom feed
From: Tim Eliseo <tre-zsh@crushedhat.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] Add option like tcsh's dextract
Date: Wed, 9 Aug 2023 15:49:00 -0700	[thread overview]
Message-ID: <fe820e0a-2c12-0cdd-5736-668bc03c621c@crushedhat.com> (raw)
In-Reply-To: <CAHYJk3TxnrfCneGS6608d4O4dhZDRosVmosQGLEtwERL6j6MpQ@mail.gmail.com>

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

On 2023-08-09 09:24:53, Mikael Magnusson wrote:
> The manpage entry says:
>    This option makes tt(pushd) using `tt(PLUS())' or `tt(-)' behave
> like tt(cd) with tt(AUTO_PUSHD) set.
>
> This is true as I understand it, but it somewhat implies that pushd
> without +/- acts differently from cd, so perhaps it should just say
> "This option makes pushd behave like cd with AUTO_PUSHD set.", which
> is also true but harder to misinterpret. (I wouldn't oppose keeping it
> as it is, it's just something that tripped me up while reading it.)

I qualified this because pushd with no arguments _does_ act differently 
from cd. Pushd (without the pushd_to_home option set) swaps the top two 
directories on the stack, while cd always goes to the home directory, 
never swaps (with or without auto_pushd).

Maybe a better rewording is something like “cd using + or - always 
extracts from the directory stack, never rotates it, regardless of the 
setting of this option.” In this way pushd becomes the reference point 
for stack manipulation (as it should be), instead of cd. The previous 
wording more belongs in the Changelog, since it’s describing what 
behavior is new relative to existing, something that is unimportant to a 
user reading the man page.

> Another thought I had was that perhaps with this option existing, the
> behavior between cd and pushd need not be different at all anymore,
> but maybe someone prefers being able to extract with cd and roll with
> pushd, so probably not worth messing with that.

I personally don’t think that the + and - variants belong with cd at 
all, because with auto_pushd it’s too similar to pushd, and without 
auto_pushd the stack rearrangement doesn’t seem very intuitive or useful 
in either case (rotate or extract). Also the stack isn’t printed after 
the command. If you have a stack that looks like:

     dir1 dir2 dir3 dir4 dir5

Current behavior of “cd +2” doing extract without auto_pushd ends up with:

     dir3 dir2 dir4 dir5

A “cd +2” doing rotate without auto_pushd (not currently possible) might 
end up with:

     dir3 dir4 dir5 dir2

Of course, we’re stuck with it now, but zsh is the only shell that has 
this. Also, as you said, someone might want to be able to use both 
extract and rotate options.

> It would also be unclear which way the default should be in that case...
>
I think unquestionably the default for pushd should be rotate, since all 
other shells that implement pushd (csh, tcsh, bash, and fish) rotate, 
with only tcsh providing the dextract option to switch to extract. If we 
were to implement a separate cd_extract option, I say it should be set 
by default, to match current behavior.

If the goal with this is to allow users to choose rotate or extract, we 
should also add command line options to override, which users can add to 
alias definitions.

I’m going to think about this some more. I’ve been working on a cd and 
pushd feature matrix for all the shells, which I’ll post later.

Tim

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

      parent reply	other threads:[~2023-08-09 22:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18  9:54 Tim Eliseo
2023-07-18 15:17 ` Mikael Magnusson
2023-08-04 16:47 ` Tim Eliseo
2023-08-04 16:58   ` Mikael Magnusson
     [not found]     ` <ee258794-761e-8f48-01d2-f0db6d8b6dc7@crushedhat.com>
2023-08-04 18:08       ` Mikael Magnusson
2023-08-05 23:48   ` Bart Schaefer
2023-08-08 22:13     ` Tim Eliseo
2023-08-09  8:50       ` Peter Stephenson
2023-08-09 13:16       ` Mikael Magnusson
2023-08-09 14:19         ` Tim Eliseo
2023-08-09 16:24           ` Mikael Magnusson
2023-08-09 17:25             ` Bart Schaefer
2023-08-09 23:27               ` Tim Eliseo
2023-08-12  3:42                 ` Bart Schaefer
2023-08-09 22:49             ` Tim Eliseo [this message]

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

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

  git send-email \
    --in-reply-to=fe820e0a-2c12-0cdd-5736-668bc03c621c@crushedhat.com \
    --to=tre-zsh@crushedhat.com \
    --cc=mikachu@gmail.com \
    --cc=zsh-workers@zsh.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.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).