From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18934 invoked by alias); 25 Oct 2014 07:25:14 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19294 Received: (qmail 22427 invoked from network); 25 Oct 2014 07:25:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=FrayJNvv c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=ruBKISyhEOuFxdlZIP4A:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <141025002453.ZM22210@torch.brasslantern.com> Date: Sat, 25 Oct 2014 00:24:53 -0700 In-reply-to: Comments: In reply to Eric Smith "Re: spell check on the command line" (Oct 24, 11:19pm) References: <141024083614.ZM20933@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: spell check on the command line MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Oct 24, 11:19pm, Eric Smith wrote: } } ~> setopt CORRECTALL } ~> touch this_settting_doess_not_yet_check_the_spelling_of_these_tags_in_a_filename.txt Oh, so you want a regular spelling dictionary applied in some way, to substrings within each command-line argument. Or perhaps only to substrings within file names, but since it's not possible to tell in general which arguments are file names (a shortcoming correctall has already), it's effectively the same problem. Let's ignore the complications of shell keywords like "elif", complex commands like loops, and multi-line buffers. Your basic choices are: - override the accept-line widget; or - create (or add to if already using one) a zle-line-finish widget; or - attempt to handle it all in prexec. The simplest one is zle-line-finish so I'll do a quick example of that here. If you do it in preexec it's more difficult to implement the (a)bort and (e)dit cases. I'll assume that anything matching [[:punct:]] is taken as a word break, and also that a program or function "suggest" exists that will spit out pairs of wrong words and their replacments (unlike "spell" which emits only the wrong words). zle-line-finish() { local spelt misspelt nyae print -R ${BUFFER//[[:punct:][:digit:]]/$'\n'} | suggest | while read misspelt spelt do read -k 1 nyae$'?\n'"correct '$misspelt' to '$spelt' [nyae]? " case ${nyae:l} in (a) zle send-break;; (e) zle push-line; return;; (y) BUFFER=${BUFFER/$misspelt/$spelt};; esac [[ -n $nyae ]] && print -nR $nyae done [[ -n $nyae ]] && { print; zle redisplay } } zle -N zle-line-finish Use at your own risk.