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

Re: [BUG] _expand completer's all-expansions tag format style does not expand %o



On Oct 19, 10:19pm, Alex George wrote:
}
} [...] the all-expansions tag does not actually expand %o unlike the
} expansions tag.
} 
} I believe the problem is the lack of a
} 
}      _description all-expansions expl all-expansions "o:$word"
} 
} line in Completion/Base/Completer/_expand.

Yes, that's essentially correct.  However, there are a few nuances.

The _requested call at line 210 makes a call to _description, passing
along the (expl 'all expansions') arguments.  However, _requested doesn't
handle passing the additional formatting strings along to _description,
so it's necessary to drop those two arguments from _requested and make
an explicit call to _description instead, handling the "menu" style as
is done for "_requested expansions".

I note in passing that it doesn't make sense to have a tag-specific
format style unless one also has a group-name style, because in the
absence of group-name all the matches end up in group "-default-"
and all the format strings get displayed together above that, and
not necessarily in related order, which can be quite distracting.

As mentioned in users/21955, I don't understand why a single match was
being excluded from the expansions tag but included in all-expansions?


diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index e52144c..a6e30e8 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -181,7 +181,7 @@ if [[ -z "$compstate[insert]" ]] ;then
 else
   _tags all-expansions expansions original
 
-  if [[ $#exp -gt 1 ]] && _requested expansions; then
+  if [[ $#exp -ge 1 ]] && _requested expansions; then
     local i j normal space dir
 
     if [[ "$sort" = menu ]]; then
@@ -207,9 +207,14 @@ else
     (( $#space ))  && compadd "$expl[@]" -UQ -qS " " -a space
     (( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal
   fi
-  if _requested all-expansions expl 'all expansions'; then
+  if _requested all-expansions; then
     local disp dstr
 
+    if [[ "$sort" = menu ]]; then
+      _description all-expansions expl 'all expansions' "o:$word"
+    else
+      _description -V all-expansions expl 'all expansions' "o:$word"
+    fi
     if [[ "${#${exp}}" -ge COLUMNS ]]; then
       disp=( -ld dstr )
       dstr=( "${(r:COLUMNS-5:)exp} ..." )
diff --git a/Completion/Base/Completer/_user_expand b/Completion/Base/Completer/_user_expand
index 066e2e8..ee39bb1 100644
--- a/Completion/Base/Completer/_user_expand
+++ b/Completion/Base/Completer/_user_expand
@@ -121,9 +121,14 @@ else
     (( $#space ))  && compadd "$expl[@]" -UQ -qS " " -a space
     (( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal
   fi
-  if _requested all-expansions expl "all expansions${REPLY:+: $REPLY}"; then
+  if _requested all-expansions; then
     local disp dstr
 
+    if [[ "$sort" = menu ]]; then
+      _description all-expansions expl "all expansions${REPLY:+: $REPLY}" "o:$word"
+    else
+      _description -V all-expansions expl "all expansions${REPLY:+: $REPLY}" "o:$word"
+    fi
     if [[ "${#${exp}}" -ge COLUMNS ]]; then
       disp=( -ld dstr )
       dstr=( "${(r:COLUMNS-5:)exp} ..." )



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