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 UAA00720 for ; Thu, 14 Nov 1996 20:03:38 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id DAA19866; Thu, 14 Nov 1996 03:52:19 -0500 (EST) Resent-Date: Thu, 14 Nov 1996 03:19:28 -0500 (EST) From: "Bart Schaefer" Message-Id: <961114002314.ZM602@candle.brasslantern.com> Date: Thu, 14 Nov 1996 00:23:14 -0800 In-Reply-To: Matthew Braun "tcsh's autocorrect functionality wanted" (Nov 11, 9:24pm) References: <199611120224.VAA24020@sassy.aa.ans.net> Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.820 20aug96) To: Matthew Braun , zsh-users@math.gatech.edu Subject: Re: tcsh's autocorrect functionality wanted MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"tqFFL2.0.mo4.FOjYo"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/502 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Nov 11, 9:24pm, Matthew Braun wrote: } Subject: tcsh's autocorrect functionality wanted } } I would like to get this tcsh functionality in zsh: } } autocorrect (+) } If set, the spell-word editor command is invoked } automatically before each completion attempt. That would be pretty trivial to add, I think, except for the bugs in spell-word described below. } What I was thinking: } } function spell-expand-or-complete-prefix { } spell-word } expand-or-complete-prefix } } } bindkey ^i spell-expand-or-complete-prefix The way you do that sort of thing is like this: # bindkey '\es' spell-word # already the default bindkey '\C-x\C-i' expand-or-complete-prefix bindkey -s '\t' '\es\C-x\C-i' However, spell-word isn't clever. It doesn't deal properly with a path beginning with a tilde (~) -- I consider this to be a bug, because this IS handled by `setopt correctall` -- and it does not know how to fix up the path prefix when the suffix is "too far" from the correct spelling. Finally, spell-word ignores `setopt completeinword` and always behaves as if `setopt awaystoend`, so the cursor ends up in what may be a very wrong place after spelling is completed. So for now you can try the binding above; or you can look at "multicomp" in the Functions/ directory of the zsh distribution, write yourself a little program that does spell checking, and replace `reply=(${~reply})' in that function with `reply=( $(spellcheck ${~reply}) )'. For a basis of the spell-checking program, you can cannibalize Src/utils.c for the functions spname(), mindist(), and spdist(). -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern