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

Re: expand style `suffix' option

Peter Stephenson wrote:

> ...
> OK, I suppose the manual is saying it works if menu completion is started
> afterwards, but not if it's already in effect.
> Since the `suffix' behaviour is selectable completely separately from
> anything else, I can't think of a good reason why the setting shouldn't
> simply be respected.  If you don't want it with menu completion you can
> simply not turn it on.

Right.  The patch below tries to make this style work again and it
also removes the dependency on not using menu completion (that part of 
the code is pretty hairy, so there might be things which now work
differently with menu-completion -- I'd like to hear about them so
that we can fix them).

> Tying settings together is really another problem entirely.  If we want
> some more general way of grouping --- set a whole load of styles all
> together - we can probably write a function suite that does it, e.g.
>   % zselect -v my_menu_styles
>   Turning on option `menuselect'
>   Changing style `expand' from `prefix suffix' to `prefix'
> However, it's not that trivial when you take contexts into account
> (compinstall has basically side-stepped this issue and while it handles
> contexts, you have to select them by hand).

Yes, I've been thinking about things like this, too, and haven't come
to a conclusion either.

The patch also tries to make the docs clearer on how the style has to
be set, because I haven't changed the code to look for sub-strings.


Index: Completion/Unix/Type/_path_files
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.11
diff -u -r1.11 _path_files
--- Completion/Unix/Type/_path_files	2001/08/17 09:25:22	1.11
+++ Completion/Unix/Type/_path_files	2001/10/05 11:11:15
@@ -332,6 +332,8 @@
     # Get the matching files by globbing.
+    tmp2=( "$tmp1[@]" )
     if [[ "$tpre$tsuf" = */* ]]; then
       compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher" "$sdirs" fake
     elif [[ "$sopt" = *[/f]* ]]; then
@@ -344,7 +346,9 @@
     if [[ -n "$PREFIX$SUFFIX" ]]; then
       # See which of them match what's on the line.
-      if [[ "$tmp1[1]" = */* ]]; then
+      if (( ! $#tmp1 )); then
+        tmp2=( ${^tmp2}/$PREFIX$SUFFIX )
+      elif [[ "$tmp1[1]" = */* ]]; then
         if [[ -n "$_comp_correct" ]]; then
           tmp2=( "$tmp1[@]" )
           builtin compadd -D tmp1 -F _comp_ignore "$matcher[@]" - "${(@)tmp1:t}"
@@ -504,13 +508,16 @@
+      # This once tested `-n $menu ||' but our menu-completion expert says
+      # that's not what we want.
-      if [[ -n $menu || -z "$compstate[insert]" ]] ||
-         ! zstyle -t ":completion:${curcontext}:paths" expand suffix ||
+      if [[ -z "$compstate[insert]" ]] ||
+         { ! zstyle -t ":completion:${curcontext}:paths" expand suffix &&
            [[ -z "$listsfx" &&
               ( -n "$_comp_correct" ||
                 -z "$compstate[pattern_match]" || "$SUFFIX" != */* ||
-                "${SUFFIX#*/}" = (|*[^\\])[][*?#~^\|\<\>]* ) ]]; then
+                "${SUFFIX#*/}" = (|*[^\\])[][*?#~^\|\<\>]* ) ]] }; then
         (( tmp4 )) && zstyle -t ":completion:${curcontext}:paths" ambiguous &&
         if [[ "$tmp3" = */* ]]; then
Index: Doc/Zsh/compsys.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.134
diff -u -r1.134 compsys.yo
--- Doc/Zsh/compsys.yo	2001/08/15 13:50:03	1.134
+++ Doc/Zsh/compsys.yo	2001/10/05 11:11:16
@@ -1070,15 +1070,15 @@
 kindex(expand, completion style)
 This style is used when completing strings consisting of multiple
-parts, such as path names.  If its
-value contains the string `tt(prefix)', the partially typed word from
+parts, such as path names.  If one of its values is
+the string `tt(prefix)', the partially typed word from
 the line will be expanded as far as possible even if trailing parts
-cannot be completed.  If it contains the string `tt(suffix)'
-and normal (non-menu-) completion is used, matching names for
+cannot be completed.  If one of its values is the string `tt(suffix)',
+matching names for
 components after the first ambiguous one will also be added.  This
 means that the resulting string is the longest unambiguous string
 possible, but if menu completion is started on the list of matches
-generated this way (e.g. due to the option tt(AUTO_MENU) being set),
+generated this way,
 this will also cycle through the names of the files in pathname
 components after the first ambiguous one.

Sven Wischnowsky                    wischnow@xxxxxxxxxxxxxxxxxxxxxxx

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