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

autocorrect: this *almost* works



Looking at docomplete(), it seems to me that we should be able to add the
tcsh autocorrect option pretty easily, by allowing spell checking to occur
and then falling through to the rest of the completion.

The following patch shows the skeleton for this change, but is NOT USABLE
as-is.  After
	    inststr(*x);
in the second hunk, it's necessary at the least to add
	    s = *x;	/* Is it OK to refer to *x beyond this point?? */
and then to restore the word-boundary and cursor-position globals before
the rest of the completion proceeds.  Unfortunately, I'm not sufficiently
familiar with this mass of cryptic two-letter variable names to get it to
do the right thing.  Anyone else care to try?  Have I missed other things
that would make this unworkable?

Of course, this still doesn't address the utter failure of spckword() on
paths beginning with a named directory ....

Random extra thought:  A variant of spckword() could return all the words
within a certain spdist() range of a given word.  This could then be used
to construct a menu in docompletion(); and we could add a menu-spell-word
function (whose prefix-arg gives the distance range?), get autocorrect to
work properly in conjunction with menucomplete and automenu, etc.

--- Src/zle_tricky.c	Thu Oct 24 03:01:48 1996
+++ Src/zle_tricky.c.new	Thu Nov 14 02:20:22 1996
@@ -673,7 +673,7 @@
 	if (lincmd && (inwhat == IN_NOTHING))
 	    inwhat = IN_CMD;
 
-	if (lst == COMP_SPELL) {
+	if (lst == COMP_SPELL || isset(AUTOCORRECT)) {
 	    char **x = &s;
 	    char *q = s;
 
@@ -686,7 +686,8 @@
 	    /* call the real spell checker, ash@xxxxxxxxxx */
 	    spckword(x, 0, lincmd, 0);
 	    inststr(*x);
-	} else if (COMP_ISEXPAND(lst)) {
+	}
+	if (COMP_ISEXPAND(lst)) {
 	    /* Do expansion. */
 	    char *ol = (olst == COMP_EXPAND_COMPLETE) ?
 		dupstring((char *)line) : (char *)line;
@@ -717,7 +718,7 @@
 			    p++, skipparens(Inbrace, Outbrace, &p);
 		docompletion(s, lst, lincmd, 1);
 	    }
-	} else
+	} else if (lst != COMP_SPELL)
 	    /* Just do completion. */
 	    docompletion(s, lst, lincmd, 0);
 	zsfree(s);

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern



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