From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: Add CORRECT_NOCOMPSYS option
Date: Sun, 5 Apr 2009 19:13:04 +0100 [thread overview]
Message-ID: <20090405191304.1908fca8@pws-pc> (raw)
In-Reply-To: <090404193718.ZM19801@torch.brasslantern.com>
On Sat, 04 Apr 2009 19:37:17 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Apr 5, 2:07am, Frank Terbeck wrote:
> }
> } This certainly is not perfect. A better solution would be to disallow
> } _commandname type function names from being the result of a correction
> } without completely disabling correction.
>
> My reservation about this is that the leading-underscore naming
> convention is (1) just that, a convention, and (2) specific to this
> implementation of the completion system -- the whole idea of putting
> the completion system into shell code was to remove this kind of
> dependency from the base shell and make it possible for anyone to
> implement their own system (admittedly increasingly unlikely at
> this point, but still).
>
> A more general solution would be an fignore-type variable, which
> compinit could set to the value "_*" or some such thing.
Right, here's a more general solution. Shout if I've missed something.
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.80
diff -u -r1.80 options.yo
--- Doc/Zsh/options.yo 26 Mar 2009 15:21:39 -0000 1.80
+++ Doc/Zsh/options.yo 5 Apr 2009 18:11:45 -0000
@@ -1007,6 +1007,9 @@
Note that, when the tt(HASH_LIST_ALL) option is not set or when some
directories in the path are not readable, this may falsely report spelling
errors the first time some commands are used.
+
+The shell variable tt(CORRECT_IGNORE) may be set to a pattern to
+match words that will never be offered as corrections.
)
pindex(CORRECT_ALL)
pindex(NO_CORRECT_ALL)
Index: Doc/Zsh/params.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v
retrieving revision 1.52
diff -u -r1.52 params.yo
--- Doc/Zsh/params.yo 3 Mar 2009 21:04:53 -0000 1.52
+++ Doc/Zsh/params.yo 5 Apr 2009 18:11:46 -0000
@@ -797,6 +797,14 @@
The number of columns for this terminal session.
Used for printing select lists and for the line editor.
)
+vindex(CORRECT_IGNORE)
+item(tt(CORRECT_IGNORE))(
+If set, is treated as a pattern during spelling correction. Any
+potential correction that matches the pattern is ignored. For example,
+if the value is `tt(_*)' then completion functions (which, by
+convention, have names beginning with `tt(_)') will never be offered
+as spelling corrections.
+)
vindex(DIRSTACKSIZE)
item(tt(DIRSTACKSIZE))(
The maximum size of the directory stack. If the
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.220
diff -u -r1.220 utils.c
--- Src/utils.c 24 Mar 2009 16:14:33 -0000 1.220
+++ Src/utils.c 5 Apr 2009 18:11:47 -0000
@@ -2236,6 +2236,7 @@
static int d;
static char *guess, *best;
+static Patprog spckpat;
/**/
static void
@@ -2243,6 +2244,9 @@
{
int nd;
+ if (spckpat && pattry(spckpat, hn->nam))
+ return;
+
nd = spdist(hn->nam, guess, (int) strlen(guess) / 4 + 1);
if (nd <= d) {
best = hn->nam;
@@ -2257,7 +2261,7 @@
mod_export void
spckword(char **s, int hist, int cmd, int ask)
{
- char *t;
+ char *t, *correct_ignore;
int x;
char ic = '\0';
int ne;
@@ -2293,6 +2297,14 @@
break;
if (**s == Tilde && !*t)
return;
+
+ if ((correct_ignore = getsparam("CORRECT_IGNORE")) != NULL) {
+ tokenize(correct_ignore = dupstring(correct_ignore));
+ remnulargs(correct_ignore);
+ spckpat = patcompile(correct_ignore, 0, NULL);
+ } else
+ spckpat = NULL;
+
if (**s == String && !*t) {
guess = *s + 1;
if (itype_end(guess, IIDENT, 1) == guess)
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2009-04-05 18:13 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-05 0:07 Frank Terbeck
2009-04-05 2:37 ` Bart Schaefer
2009-04-05 12:23 ` Frank Terbeck
2009-04-05 18:13 ` Peter Stephenson [this message]
2009-04-05 22:11 ` Bart Schaefer
2009-04-06 9:09 ` Peter Stephenson
2009-05-27 16:30 ` Richard Hartmann
2009-05-27 16:59 ` Peter Stephenson
2009-05-27 19:12 ` Greg Klanderman
2009-05-28 8:48 ` Richard Hartmann
2009-05-28 9:25 ` Frank Terbeck
2009-05-28 18:44 ` Greg Klanderman
2009-05-28 19:03 ` Frank Terbeck
2009-05-28 19:35 ` Peter Stephenson
2009-05-28 22:56 ` Greg Klanderman
2009-05-29 8:32 ` Peter Stephenson
2009-05-29 14:38 ` Greg Klanderman
2009-05-29 14:49 ` Peter Stephenson
2011-03-01 20:39 ` PATCH: zstyle to control completion of functions/parameters beginning with underscore Greg Klanderman
2011-03-01 21:11 ` Peter Stephenson
2011-03-01 22:07 ` Greg Klanderman
2011-03-02 1:05 ` Oliver Kiddle
2011-03-02 18:49 ` Greg Klanderman
2011-03-02 23:30 ` Bart Schaefer
2011-03-03 15:33 ` Greg Klanderman
2011-03-03 16:11 ` Greg Klanderman
2011-03-03 16:54 ` Bart Schaefer
2011-03-06 20:07 ` Greg Klanderman
2011-03-06 22:02 ` Bart Schaefer
2011-03-08 15:13 ` Greg Klanderman
2011-03-09 18:41 ` Greg Klanderman
2011-03-10 15:54 ` Bart Schaefer
2011-03-10 16:44 ` Greg Klanderman
2011-03-10 17:10 ` Bart Schaefer
2011-03-10 18:01 ` Greg Klanderman
2011-03-11 17:01 ` Greg Klanderman
2011-03-03 16:58 ` Oliver Kiddle
2011-03-02 1:13 ` Richard Hartmann
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=20090405191304.1908fca8@pws-pc \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@sunsite.dk \
/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).