From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-request@euclid.skiles.gatech.edu Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.6/8.7.3) with ESMTP id WAA01351 for ; Thu, 14 Nov 1996 22:14:07 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id GAA20858; Thu, 14 Nov 1996 06:03:46 -0500 (EST) Resent-Date: Thu, 14 Nov 1996 06:03:46 -0500 (EST) From: "Bart Schaefer" Message-Id: <961114030739.ZM2655@candle.brasslantern.com> Date: Thu, 14 Nov 1996 03:07:39 -0800 Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@math.gatech.edu Subject: autocorrect: this *almost* works MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"-5aFd2.0.q55.HolYo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2407 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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@aaii.oz.zu */ 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