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

Re: correction hook



 --- Clint Adams <clint@xxxxxxx> wrote:
> Someone complained to me that when he mistyped "make" as "mak", zsh
> would spell-correct it to "mawk" instead of "make".  I had asked him
> for
> a proposed algorithm to solve this, but he had none.
> 
> The thought then occurred to me that a hook function might be a bit
> more
> flexible.  With the following patch, one can now do something like
> 
> correctword() {
> [[ "$1" == mak ]] && CORRECT_GUESS=make
> }

I haven't been able to try the patch but how would this work if the
CORRECT_ALL option is set and there are corrections to be made to more
than one word on the command-line. Perhaps the REPLY array could be
used instead of one scalar so that all words can be set.

> or potentially something more sophisticated that couldn't be 
> accomplished as effectively as by alias mak=make.

Aliases have served me well for the few common typos like this. I have
reservations about this because this simple function probably doesn't
go far enough. How might you disable correction for certain words, e.g.
the destination to a mv command?

I'm not entirely convinced by the correction mechanism because it has
to interrupt you with its prompt. With the new completion system I get
any typo in a word I completed corrected by _approximate anyway. I'd be
more inclined to think about a totally different way of spotting and
communicating typos such as using the completion system continually and
underlining possible typos.

Oliver

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com



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