zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [PATCH?] Re: Autocorrect for commands with a hyphen (dash) in the name
Date: Sun, 24 May 2020 11:39:52 -0700	[thread overview]
Message-ID: <CAH+w=7bSu-HTLWCAxP2tkLL7uWRxF9FSgggbOyK=jxp1jJt5+Q@mail.gmail.com> (raw)
In-Reply-To: <2d5fcc3630beeec538b7b4dc334991da7420968e.camel@ntlworld.com>

On Sun, May 24, 2020 at 10:12 AM Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
>
> > You mean you think we can unify lex.c
> > and zle_tricky.c inside spckword()?
>
> Yes, at the moment spckword() is expecting a sort of slightly tokenised
> here and there string, which isn't a particular great interface.

There's a problem with this to which I don't see an immediate solution:

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.

In zle_tricky.c it is actually strcmp()'d against the input string,
even though zle_tricky.c then immediately untokenizes it again to
actually insert it on the command line.  You said:
> If the spell check worked,
> the result is just a normal word.
We'll at least have to change spckword() from a void function to one
that returns a status of whether it found a guess, because otherwise
"check worked" is a matter of that strcmp().

lex.c seems to want it tokenized, because it then does something
similar to untokenize() except it also converts Nularg (which
untokenize() skips over).  Maybe there are guaranteed not to be any
Nularg at that point.

This is all very messy.  Also, confirm that hash tables are stored untokenized?

  reply	other threads:[~2020-05-24 18:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAOoO2vg=-9P7v=ATOzrbh6VF35o_xzK_-yF+EA6OgTHsQBik-A@mail.gmail.com>
     [not found] ` <CAH+w=7bKpm7GO2ZhbA5Apr0sBDz5=kmX1=WK2X0nTcWxpkHPPQ@mail.gmail.com>
     [not found]   ` <ab8b7655-83e8-45b2-889f-043314faea62@www.fastmail.com>
     [not found]     ` <CAH+w=7aqAO37qpSvtmJXMPWq3zP=pUAZCe3i-BFyn0knRmFjVQ@mail.gmail.com>
2020-05-23 19:33       ` Bart Schaefer
2020-05-23 19:44         ` Peter Stephenson
2020-05-23 19:54           ` Bart Schaefer
2020-05-23 20:30             ` Peter Stephenson
2020-05-23 21:18               ` Bart Schaefer
2020-05-24 17:11                 ` Peter Stephenson
2020-05-24 18:39                   ` Bart Schaefer [this message]
2020-05-25  5:46                     ` Bart Schaefer
2020-05-25 16:35                       ` Peter Stephenson
2020-05-25 21:45                         ` Bart Schaefer
2020-05-30 21:25                           ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7bSu-HTLWCAxP2tkLL7uWRxF9FSgggbOyK=jxp1jJt5+Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).