zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: [BUG] With CORRECT_ALL, an interrupted correct puts a truncated entry in history
Date: Wed, 6 Dec 2023 16:03:33 +0100	[thread overview]
Message-ID: <20231206150333.GA385094@zira.vinc17.org> (raw)
In-Reply-To: <CAH+w=7bFpEhKjPB7RkAMi=zdwNb6pE5OZnTgtTEWJXBSm2p-9g@mail.gmail.com>

On 2023-12-05 13:22:07 -0800, Bart Schaefer wrote:
> On Tue, Dec 5, 2023 at 4:57 AM Vincent Lefevre <vincent@vinc17.net> wrote:
> >
> > I thought that this would have been put in a temporary buffer,
> > until the (possibly corrected) command is validated.
> 
> I'm not sure what you think "validated" means here.

Once the user has no longer any way to discard the command line,
which will then be really run.

> > I think that ^C and 'a' should just skip the history.
> 
> I'm not going to make a decision on that without further feedback.  I
> know that when I use 'a' at the "correct" prompt, I often do
> eventually want to go back and re-execute the command even if I wasn't
> ready to 'e'dit it at the moment of the correction.

Yes, that's why I had suggested an explicit action for that, in my
first message:

│Nothing about the history. I think that the history shouldn't be
│changed. But in this case, a new action (e.g. 'h' for "history")
│to discard the entire command line and put it in the history
│could be useful in some occasions.

Or just use 'e', then immediately put the command in the history
without running it. Is there a zle widget for that? I would find
this useful even when there are no spelling corrections.

Note that I often recall commands from the history, but sometimes,
this isn't the right context, so that I may get a spelling correction
after hitting [Enter] or ^O (accept-line-and-down-history). Putting
the command in the history again if I abort ('a') is not needed in
such a case and will even conflict with a possible future use of ^O
(because I won't execute the subsequent commands after an abort).

> > In particular, the current 'n' one is very ambiguous, because one may
> > want to run the command without any additional prompt for corrections.
> > So perhaps there should be a real
> >
> >     r (`run`)
> 
> Why would you want "discard all and run" but not "accept all and run"?

IMHO, "accept all and run" is potentially dangerous as one doesn't
know the spelling corrections. Proposed spelling corrections are
useful, but they are often wrong (e.g. for files to be created or
arguments that are not filenames) since the spelling correction
mechanism doesn't know the meaning of the arguments (unlike the
completion mechanism).

With "discard all and run", the user knows what will be executed.
This can be useful when recalling complex commands from the history.
In general, such commands have the correct spelling.

>  Anyway I think that's more typically handled by distinguishing 'n'
> /'N' and 'y'/'Y', although (see above) 'a' already discards all.

but the difference with 'n'/'N'/'y'/'Y' is that 'a' does not run
the command.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


  reply	other threads:[~2023-12-06 15:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05  2:12 Vincent Lefevre
2023-12-05  4:10 ` Bart Schaefer
2023-12-05 12:57   ` Vincent Lefevre
2023-12-05 21:22     ` Bart Schaefer
2023-12-06 15:03       ` Vincent Lefevre [this message]
2023-12-09 21:44         ` Bart Schaefer
2023-12-17 13:54           ` Vincent Lefevre
2023-12-17 19:37             ` Bart Schaefer
2023-12-18  3:37               ` Vincent Lefevre
2023-12-18  6:36                 ` Bart Schaefer
2024-01-21  5:06     ` Bart Schaefer

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=20231206150333.GA385094@zira.vinc17.org \
    --to=vincent@vinc17.net \
    --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).