about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTomoki Sekiyama <tomoki.sekiyama@gmail.com>2014-04-28 10:11:33 -0400
committerPeter Stephenson <pws@zsh.org>2014-04-29 10:44:09 +0100
commit0da28f323d790a79d965d9cec48604c97e03f4b8 (patch)
treefd38cf067b741d0c290c57048e84cb10454851d4
parent9cd7ffe529981d9c1520a323b542a41eedbddc14 (diff)
downloadzsh-0da28f323d790a79d965d9cec48604c97e03f4b8.tar.gz
zsh-0da28f323d790a79d965d9cec48604c97e03f4b8.tar.xz
zsh-0da28f323d790a79d965d9cec48604c97e03f4b8.zip
32592: add CORRECT_IGNORE_FILE variable
-rw-r--r--ChangeLog4
-rw-r--r--Doc/Zsh/options.yo3
-rw-r--r--Doc/Zsh/params.yo8
-rw-r--r--Src/utils.c11
4 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0dcbf3e75..377ae2207 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-29  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* Tomoki Sekiyama: 32592: add CORRECT_IGNORE_FILE variable.
+
 2014-04-23  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* Sebastien Alaiwan: 32562: Completion/Unix/Command/_bzr:
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index fbcf28ccb..f7e11d20f 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1098,6 +1098,9 @@ pindex(CORRECTALL)
 pindex(NOCORRECTALL)
 item(tt(CORRECT_ALL) (tt(-O)))(
 Try to correct the spelling of all arguments in a line.
+
+The shell variable tt(CORRECT_IGNORE_FILE) may be set to a pattern to
+match file names that will never be offered as corrections.
 )
 pindex(DVORAK)
 pindex(NO_DVORAK)
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 8d95355f9..c1cb9739d 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -917,6 +917,14 @@ 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(CORRECT_IGNORE_FILE)
+item(tt(CORRECT_IGNORE_FILE))(
+If set, is treated as a pattern during spelling correction of file names.
+Any file name that matches the pattern is never offered as a correction.
+For example, if the value is `tt(.*)' then dot file names will never be
+offered as spelling corrections.  This is useful with the
+tt(CORRECT_ALL) option.
+)
 vindex(DIRSTACKSIZE)
 item(tt(DIRSTACKSIZE))(
 The maximum size of the directory stack, by default there is no limit.  If the
diff --git a/Src/utils.c b/Src/utils.c
index e1fd7a35b..943922725 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -2491,7 +2491,7 @@ getquery(char *valid_chars, int purge)
 
 static int d;
 static char *guess, *best;
-static Patprog spckpat;
+static Patprog spckpat, spnamepat;
 
 /**/
 static void
@@ -2562,6 +2562,13 @@ spckword(char **s, int hist, int cmd, int ask)
     } else
 	spckpat = NULL;
 
+    if ((correct_ignore = getsparam("CORRECT_IGNORE_FILE")) != NULL) {
+	tokenize(correct_ignore = dupstring(correct_ignore));
+	remnulargs(correct_ignore);
+	spnamepat = patcompile(correct_ignore, 0, NULL);
+    } else
+	spnamepat = NULL;
+
     if (**s == String && !*t) {
 	guess = *s + 1;
 	if (itype_end(guess, IIDENT, 1) == guess)
@@ -3783,6 +3790,8 @@ mindist(char *dir, char *mindistguess, char *mindistbest)
     if (!(dd = opendir(unmeta(dir))))
 	return mindistd;
     while ((fn = zreaddir(dd, 0))) {
+	if (spnamepat && pattry(spnamepat, fn))
+	    continue;
 	nd = spdist(fn, mindistguess,
 		    (int)strlen(mindistguess) / 4 + 1);
 	if (nd <= mindistd) {