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

Re: Remove space added by completion



On 15 Feb, zzapper wrote:
> > It might be useful to have a specific example of an unwanted space.
> alias -g NF='*~vssver.scc(.om[1])'
> ls NF<TAB>

_expand looks at an add-space style to see whether to add a space suffix
so it seems logical for _expand_alias to also observe that style. At
least only for a true/false value (_expand has special handling for
files/directories).

Note that _expand_alias is using expand-alias-word in the zstyle
context which is perhaps not what you'd first guess.

Oliver

diff --git a/Completion/Base/Completer/_expand_alias b/Completion/Base/Completer/_expand_alias
index 8848e66..8240e41 100644
--- a/Completion/Base/Completer/_expand_alias
+++ b/Completion/Base/Completer/_expand_alias
@@ -1,7 +1,7 @@
 #compdef -K _expand_alias complete-word \C-xa
 
 local word expl tmp pre sel what
-local -a tmpa
+local -a tmpa suf
 
 eval "$_comp_setup"
 
@@ -58,7 +58,8 @@ if [[ -n $tmp ]]; then
       tmp="\\$tmp"
     fi
   fi
-  $pre _wanted aliases expl alias compadd -UQ -- ${tmp%%[[:blank:]]##}
+  zstyle -T ":completion:${curcontext}:" add-space || suf=( -S '' )
+  $pre _wanted aliases expl alias compadd -UQ "$suf[@]" -- ${tmp%%[[:blank:]]##}
 elif (( $#pre )) && zstyle -t ":completion:${curcontext}:" complete; then
   $pre _aliases -s "$sel" -S ''
 else



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