From b148a56869958ee691c57ddaf633a8a4e038b3dc Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 6 Apr 2009 09:06:35 +0000 Subject: 26806 (doc tweaked): Add CORRECT_IGNORE variable --- ChangeLog | 7 ++++++- Doc/Zsh/options.yo | 3 +++ Doc/Zsh/params.yo | 11 +++++++++++ Src/utils.c | 14 +++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b446340a2..c9b0ca9d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-04-06 Peter Stephenson + + * 26806 (doc tweaked): Add CORRECT_IGNORE variable for pattern to + be ignored by correction from internal hash tables. + 2009-04-04 Clint Adams * Simon Ruderich: 26800: Completion/Unix/Command/_git: fixes for "git add" @@ -11513,5 +11518,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.4642 $ +* $Revision: 1.4643 $ ***************************************************** diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index 6b3ba34e8..0a03c8272 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -1007,6 +1007,9 @@ Try to correct the spelling of commands. 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) diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index dec742f07..7a8efdd94 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -797,6 +797,17 @@ item(tt(COLUMNS) )( 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. The pattern does not apply the correction +of file names, as applied by the tt(CORRECT_ALL) option (so with the +example just given files beginning with `tt(_)' in the current +directory would still be completed). +) vindex(DIRSTACKSIZE) item(tt(DIRSTACKSIZE))( The maximum size of the directory stack. If the diff --git a/Src/utils.c b/Src/utils.c index cf375821d..d259827a9 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -2236,6 +2236,7 @@ getquery(char *valid_chars, int purge) static int d; static char *guess, *best; +static Patprog spckpat; /**/ static void @@ -2243,6 +2244,9 @@ spscan(HashNode hn, UNUSED(int scanflags)) { 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 @@ spscan(HashNode hn, UNUSED(int scanflags)) 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 @@ spckword(char **s, int hist, int cmd, int ask) 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) -- cgit 1.4.1