From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1171 invoked from network); 21 Oct 2007 22:55:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.2.3 Received: from ns2.primenet.com.au (HELO primenet.com.au) (@203.24.36.3) by ns1.primenet.com.au with (DHE-RSA-AES256-SHA encrypted) SMTP; 21 Oct 2007 22:55:44 -0000 Received: (qmail 22580 invoked from network); 21 Oct 2007 21:46:45 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by proxy.melb.primenet.com.au with SMTP; 21 Oct 2007 21:46:45 -0000 Received-SPF: none (proxy.melb.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 92080 invoked from network); 21 Oct 2007 21:45:39 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Oct 2007 21:45:39 -0000 Received: (qmail 27650 invoked by alias); 21 Oct 2007 21:45:31 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12073 Received: (qmail 27631 invoked from network); 21 Oct 2007 21:45:30 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Oct 2007 21:45:30 -0000 Received: (qmail 90835 invoked from network); 21 Oct 2007 21:45:30 -0000 Received: from vms046pub.verizon.net (206.46.252.46) by a.mx.sunsite.dk with SMTP; 21 Oct 2007 21:45:23 -0000 Received: from torch.brasslantern.com ([71.116.76.59]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JQA00FO973CTYZW@vms046.mailsrvcs.net> for zsh-users@sunsite.dk; Sun, 21 Oct 2007 16:45:13 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id l9LLjBIp031242 for ; Sun, 21 Oct 2007 14:45:12 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id l9LLjBAl031241 for zsh-users@sunsite.dk; Sun, 21 Oct 2007 14:45:11 -0700 Date: Sun, 21 Oct 2007 14:45:11 -0700 From: Bart Schaefer Subject: Re: Improving spelling correction prompt to generate aliases for future use In-reply-to: <200710211804.l9LI4w23004771@pws-pc.ntlworld.com> To: zsh-users@sunsite.dk Message-id: <071021144511.ZM31240@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <200710211804.l9LI4w23004771@pws-pc.ntlworld.com> Comments: In reply to Peter Stephenson "Re: Improving spelling correction prompt to generate aliases for future use" (Oct 21, 7:04pm) On Oct 21, 7:04pm, Peter Stephenson wrote: } } You could "setopt promptsubst" and have typo output the prompt (as } well as whatever else it's doing) I don't think that'll do what Gwern is after. He wants to feed the results (original and suggested replacement) of spelling correction to "typo" as command-line arguments. E.g. he wants to do typo ${(%):-%R} ${(%):-%r} but he can't because prompt substitution in parameters doesn't have access to the SPROMPT escapes. The following works for simple commands but not loop constructs or other compound commands: accept-line() { emulate -L zsh local -a words words=(${(z)BUFFER}) typeset -g ACCEPTED_CMD=$words[1] zle .accept-line "$@" } zle -N accept-line preexec() { emulate -L zsh local -a words words=(${(z)1}) if [[ $words[1] != $ACCEPTED_CMD ]] then typo $ACCEPTED_CMD $words[1] fi }