Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Autocorrect for commands with a hyphen (dash) in the name
- X-seq: zsh-users 24857
- From: "Daniel Shahaf" <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Autocorrect for commands with a hyphen (dash) in the name
- Date: Tue, 19 May 2020 00:52:02 +0000
- In-reply-to: <CAH+w=7bKpm7GO2ZhbA5Apr0sBDz5=kmX1=WK2X0nTcWxpkHPPQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAOoO2vg=-9P7v=ATOzrbh6VF35o_xzK_-yF+EA6OgTHsQBik-A@mail.gmail.com> <CAH+w=7bKpm7GO2ZhbA5Apr0sBDz5=kmX1=WK2X0nTcWxpkHPPQ@mail.gmail.com>
Bart Schaefer wrote on Tue, 19 May 2020 00:38 +00:00:
> On Mon, May 18, 2020 at 5:16 PM Seth Tisue <seth@xxxxxxxxx> wrote:
> >
> > ...doesn't work, in either zsh 5.7 or 5.8:
> > [...]
> > but the same isn't true for underscores:
> > [...]
> > seems like a bug?
>
> On a quick glance at the code, it appears hyphen is considered to be
> "close to" a number, whereas underscore is considered to be "close to"
> a letter. This may have something to do with a long-ago transcription
> of a then-common keyboard layout.
>
> Autocorrect isn't really a spelling checker, despite everything that's
> said about it. It's a typographical error checker comparing the
> command word to something it can look up in the command hash table.
> So it'll fail if the hash table isn't filled yet, or if it decides
> your input is too "far away" to be a typo.
I think there may be more to it than that. spckword() expects its first
argument, *s, to be unmetafied; however, when that function is called
from the «isset(CORRECT)» codepath, *s is metafied.
The zle callsite passes an unmetafied string, and invoking the spell-word
widget correctly corrects a word that isset(CORRECT) does not correct.
Seth, as a workaround you can use the spell-word widget.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author