From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16765 invoked from network); 25 May 2020 16:36:29 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 25 May 2020 16:36:29 -0000 Received: (qmail 26251 invoked by alias); 25 May 2020 16:36:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45912 Received: (qmail 28438 invoked by uid 1010); 25 May 2020 16:36:22 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-10.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25821. spamassassin: 3.4.4. Clear:RC:0(80.0.253.74):SA:0(-2.0/5.0):. Processed in 3.287463 secs); 25 May 2020 16:36:22 -0000 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.74 as permitted sender) X-Originating-IP: [86.16.88.158] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=YvshubQX c=1 sm=1 tr=0 a=MiHCjVqLJ44lE3bxSlffFQ==:117 a=MiHCjVqLJ44lE3bxSlffFQ==:17 a=IkcTkHD0fZMA:10 a=Yi_PFY6fXaWVmkGjOKMA:9 a=QEXdDO2ut3YA:10 Message-ID: <16a92121a737d366f8f0049bacb375c1693e5ca6.camel@ntlworld.com> Subject: Re: [PATCH?] Re: Autocorrect for commands with a hyphen (dash) in the name From: Peter Stephenson To: zsh-workers@zsh.org Date: Mon, 25 May 2020 17:35:42 +0100 In-Reply-To: References: <22f19bb4707e388629092d2e8673d8294fa8e375.camel@ntlworld.com> <2d5fcc3630beeec538b7b4dc334991da7420968e.camel@ntlworld.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfKAezwhiGVJfWibn7IPnczTHefRGiIWyBa1ZQd4A9F7onC2Cu/VLz5dNsTS9aHtV0VL2WH5yQU+B4A8CjRbyOTRIpU94i2xe8nmucNBbDVqLGY2qm4FN zQjB1xmo9atwsjXYlqYRxLafHBfxaoxNqTYFH7slOTyp8P2wNMXHvYCd On Sun, 2020-05-24 at 22:46 -0700, Bart Schaefer wrote: > > spckword() modifies the original input string in place, to return the > > best guess. In both lex.c and zle_tricky.c, that result string is > > then used in later code, which means if it goes in tokenized it ought > > to come back out that way as well. > > Maybe this is just the best way to deal with this mess. I think this might be a good approach, given all the complexities the other way, but I'd suggest a dupstring if we find a Dash --- three aren't so many cases that need it, mostly limited to idiotic parsing requirements in POSIX-compliant contexts, but I don't think we can guarantee they don't intersect with cases where spell checking is live. pws > diff --git a/Src/utils.c b/Src/utils.c > index 5158a70..118e132 100644 > --- a/Src/utils.c > +++ b/Src/utils.c > @@ -3151,8 +3151,12 @@ spckword(char **s, int hist, int cmd, int ask) > if (*t == Tilde || *t == Equals || *t == String) > t++; > for (; *t; t++) > - if (itok(*t)) > - return; > + if (itok(*t)) { > + if (*t == Dash) > + *t = '-'; > + else > + return; > + } > best = NULL; > for (t = *s; *t; t++) > if (*t == '/')