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

Re: _files does not list files after foo/



Peter Stephenson wrote:

> 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.

This isn't subtle at all, but I wouldn't like to have to decide
whether I want `gunzip' to work correctly or if I want to avoid this
correction-of-correct-directory-names.

So the patch below does the correction-avoidance-thingy only if
`_path_files' didn't get any of the pattern options (`-g' and `-/').

It also removes the `path_keepdir' key again -- I'm not too sure
about this. Should I put it back again? Or should we replace it by a
configuration key with the reverse meaning (and name)?

Bye
 Sven

diff -u oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files	Mon Aug  2 11:45:15 1999
+++ Completion/Core/_path_files	Mon Aug  2 15:35:30 1999
@@ -25,7 +25,7 @@
 
 local linepath realpath donepath prepath testpath exppath
 local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf
-local pats ignore group expl addpfx addsfx remsfx
+local pats haspats=no ignore group expl addpfx addsfx remsfx
 local nm=$compstate[nmatches] menu
 
 typeset -U prepaths exppaths
@@ -82,9 +82,11 @@
 	 ;;
   /)     sopt="${sopt}/"
          pats=("$pats[@]" '*(-/)')
+	 haspats=yes
 	 ;;
   g)     gopt='-g'
          pats=("$pats[@]" ${=OPTARG})
+	 haspats=yes
 	 ;;
   esac
 done
@@ -259,14 +261,11 @@
       # an attempt to correct a valid directory name. So we just add the
       # original string in such a case so that the command line doesn't 
       # change but other completers still think there are matches.
+      # We do this only if we weren't given a `-g' or `-/' option because
+      # otherwise this would keep `_files' from completing all filenames
+      # if none of the patterns match.
 
-      # 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" &&
+      if [[ "$haspats" = no && -z "$tpre$tsuf" &&
 	"$pre" = */ && -z "$suf" ]]; then
         compadd -nQS '' - "$linepath$donepath$orig"
         tmp4=-
diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- od/Zsh/compsys.yo	Mon Aug  2 11:45:23 1999
+++ Doc/Zsh/compsys.yo	Mon Aug  2 15:34:30 1999
@@ -738,7 +738,7 @@
 `tt(-S)', `tt(-q)', `tt(-r)', and `tt(-R)' options from the
 tt(compadd) builtin.
 
-Finally, the tt(_path_files) function supports three configuration keys.
+Finally, the tt(_path_files) function supports two configuration keys.
 startitem()
 item(tt(path_expand))(
 If this is set to any non-empty string, the partially
@@ -749,14 +749,6 @@
 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()
 )

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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