Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _files does not list files after foo/



Tanaka Akira wrote:
> Z(2):akr@is27e1u11% zsh -f         
> is27e1u11% autoload -U compinit; compinit -D
> is27e1u11% gunzip ./<TAB>
> 
> After above operation, zsh does not list files in current directory.
> 
> OK, I know that the behaviour is intentional as:
> 
> But it is confusing in this case.
> I suppose that there should be the way to disable the hack.

Yes, in fact in the case of something like `_files *(*)' it's preventing
the second call of _path_files from trying to look for directories when
there aren't any other matches, which is quite a serious problem (note that
it only arises right after the /, but with menu completion that's where I
mostly use completion nowadays).  This turns it off unless the path_keepdir
configuration key is set.  Maybe Sven can think of something more subtle to
do.

--- Completion/Core/_path_files.bak	Tue Jul 27 15:54:39 1999
+++ Completion/Core/_path_files	Tue Jul 27 15:54:49 1999
@@ -260,7 +260,14 @@
       # original string in such a case so that the command line doesn't 
       # change but other completers still think there are matches.
 
-      if [[ -z "$tpre$tsuf" && "$pre" = */ && -z "$suf" ]]; then
+      # Problem:  this seems to stop _files from finding directory
+      # completions if there were no file completions, for
+      # example `_files *(*)' no longer completes subdirectories after
+      # a /.  For now, make this a configuration option, but
+      # probably it needs to be done better.
+
+      if [[ -n "$compconfig[path_keepdir]" && -z "$tpre$tsuf" &&
+	"$pre" = */ && -z "$suf" ]]; then
         compadd -nQS '' - "$linepath$donepath$orig"
         tmp4=-
       fi
--- Doc/Zsh/compsys.yo.bak	Fri Jul 23 13:41:43 1999
+++ Doc/Zsh/compsys.yo	Tue Jul 27 16:00:27 1999
@@ -728,13 +728,27 @@
 `tt(-S)', `tt(-q)', `tt(-r)', and `tt(-R)' options from the
 tt(compadd) builtin.
 
-Finally, the tt(_path_files) function supports two configuration keys.
-If tt(path_expand) is set to any non-empty string, the partially
+Finally, the tt(_path_files) function supports three configuration keys.
+startitem()
+item(tt(path_expand))(
+If this is set to any non-empty string, the partially
 typed path from the line will be expanded as far as possible even if
-trailing pathname components can not be completed. And if
-tt(path_cursor) is set to a non-empty string, the cursor will be left
+trailing pathname components can not be completed.
+)
+item(tt(path_cursor))(
+If this is set to a non-empty string, the cursor will be left
 after the first ambiguous pathname component even when menucompletion
 is used.
+)
+item(tt(path_keepdir))(
+If this is set to a non-empty string, then if completion immediately after
+a slash fails, treat the original string as a successful completion.  This
+prevents a valid directory being treated as a candidate for correction.
+However, it has the side effect that a pattern completion, such as
+`tt(files -g *(*))', will no longer try to complete directories in this
+position if there are no file matches.
+)
+enditem()
 )
 item(tt(_parameters))(
 This should be used to complete parameter names if you need some of the

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author