Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] With CORRECT_ALL, an interrupted correct puts a truncated entry in history



On Sun, Dec 17, 2023 at 7:37 PM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
>
> There could have been a special history file for aborts.

Time-travel is not a likely solution ...

> Or perhaps
> the history file could have some flag for commands that are in the
> history but have never been run.

That would get rather messy given the existence of shared history and
of "print -s".

> Note that in many cases when I want to abort is when the command
> already comes from the history. So there's no point saving it again
> in general.

The widget version from my previous message saves only the $PREBUFFER
on abort.  If you've recalled a multi-line construct from history,
PREBUFFER will be empty.

Presently ^C ends up acting like 'e' because I haven't gotten around
to signal handling yet.

> What I intended to mean was just a widget that puts a command in the
> history without running it.

hist-no-exec() {
  print -s "$BUFFER"
  zle send-break
}
zle -N hist-no-exec

Unfortunately this doesn't prevent $PREBUFFER from being saved as its own entry.

> > That said ... attached is an actual ZLE implementation of correctall.
>
> I would be much more interested in a "correctnone"

I gathered that before, which is why the correct-all-words widget adds
the '!' response.

The other typical way to get this is to use the "nocorrect" precommand modifier.




Messages sorted by: Reverse Date, Date, Thread, Author