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

Re: Completion of files in subdirectories



On Sep 2,  1:23pm, Vincent Lefevre wrote:
} Subject: Completion of files in subdirectories
}
} It seems that the completion of files in subdirectories is broken
} for commands that have a filter on the extension (e.g. ".pdf" for
} xpdf, ".html" for lynx).

Hrm.

I really have only the most general notion of whether the comment I
have added in the patch below is correct.  There are way too many
possible variations here.  In particular I could imagine a command
that wants to filter out subtrees by pattern on the directory name.

Index: Completion/Unix/Type/_path_files
===================================================================
--- Completion/Unix/Type/_path_files	1 Jun 2011 06:39:59 -0000
+++ Completion/Unix/Type/_path_files	2 Sep 2011 15:56:52 -0000
@@ -438,8 +438,19 @@
 
     tmp2=( "$tmp1[@]" )
 
-    if [[ "$tpre$tsuf" = */* ]]; then
-      compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]"
"$sdirs" fake
+    if [[ "$tpre$tsuf" = (#b)*/(*) ]]; then
+
+      # We are going to be looping over the leading path segments.
+      # This means we should not apply special-dirs handling unless
+      # the path tail is a fake directory that needs to be simulated,
+      # and we should not apply pattern matching until we are looking
+      # for files rather than for intermediate directories.
+
+      if [[ -n "$fake${match[1]}" ]]; then
+        compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake
+      else
+        compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" '' fake
+      fi
     elif [[ "$sopt" = *[/f]* ]]; then
       compfiles -p$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]"
"$sdirs" fake "$pats[@]"
     else



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