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

RE: PATCH: cleanup in zle_tricky.c



Andrej Borsenkow wrote:

> Now, that I have been working with this a bit more, the result of this patch
> is somewhat unexpected. Now, the /a/b/c/d expands the prefix even if nothing
> would match. Returning to my expamle - the bug with /u/i/s/*.h was, that
> this does match, but the match failed (because of bug). And current
> /u/i/s/*.c -> /usr/include/sys/*.c is a bit too much ...
> 
> ...
> 
> May I suggest, that this change would be backed off? Probably, with
> configuration option (but I fail to see, when it would be useful). If direct
> completion of /a/b/c/d fails, this is the job for approximate/correcting
> completion then.
> 
> To be more precise - the change makes prefix to be expanded even if nothing
> matches. I did not intend it, and did not ask for it.

Without `GLOB_COMPLETE' you need this to make `/u/i/s/*.h<TAB>' to
expand the path, because there is no file named `*.h' (there are only
files matching `*.h' which isn't tested without `GLOB_COMPLETE').

Anyway, I've made it configurable (set `compconf path_expand=yes'),
because I also like to be able to do `:> com/cor/_frob<TAB>' to expand 
the path even if `_frob' doesn't exist already.

Bye
 Sven

diff -u -r oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files	Wed Mar 24 13:19:00 1999
+++ Completion/Core/_path_files	Wed Mar 24 13:21:35 1999
@@ -12,6 +12,14 @@
 # like files with one of the suffixes in the `fignore' array in normal
 # completion.
 #
+# This function supports one configuration key:
+#
+#  path_expand
+#    If this is set to a 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.
+#
+#
 # This function uses the helper functions `_match_test' and `_match_pattern'.
 
 # First see if we should generate matches for the global matcher in use.
@@ -454,7 +462,8 @@
 
 exppaths=( "${(@)exppaths:#$orig}" )
 
-if [[ nm -eq compstate[nmatches] && $#exppaths -ne 0 ]]; then
+if [[ -n "$compconfig[path_expand]" &&
+      nm -eq compstate[nmatches] && $#exppaths -ne 0 ]]; then
   compadd -UQ -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" - \
           "${linepath}${(@)^exppaths}"
 fi
diff -u -r oc/README Completion/README
--- oc/README	Wed Mar 24 13:19:01 1999
+++ Completion/README	Wed Mar 24 13:23:04 1999
@@ -152,7 +152,7 @@
 
 You can configure several aspects of the completion functions and the
 overall completion behavior using the compconf shell function defined
-in compinit. This function get any number of arguments of the form
+in compinit. This function gets any number of arguments of the form
 `key=value', where `key' is one of the keys described below and `value'
 is any string. Most configuration keys are defined by the completer
 functions.
@@ -333,7 +333,14 @@
     to the one completion was called on the last time will not
     delay the generation of matches.
 
-
 For more information about what the completers do, see the files
 containing them (_complete, _correct, _approximate, _match, and
 _expand in the Core directory).
+
+The _path_files function used to complete filenames has one
+configuration key:
+
+  path_expand
+    If this is set to a 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.

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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