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

Re: help with _match, globcomplete etc. (with a PATCH)



Sven Wischnowsky wrote:

> Err, substitution is done in lines 30/31, so your new style only says
> that it should offer expansion only if attempting globbing did change
> the word resulting from substitution (given that I don't really
> understand the style name but maybe I'm the only one). I think it's
> fine to have that configurable.

Globbing wouldn't work without substitution being done first where there are variables etc in the line. The option allows me to have the benefit of globbing (at the expense of substition) in these cases without having substition for everything. So the effect is that only globbed things are substituted hence the name subst-only-globs. If anyone can think of a better name, its easily changed.

> Well, I'd say since the completion code normally adds slashes for
> directories we probably don't need a style for it as long as we add it
> with `-qS/', i.e. auto-removable.

A patch for this follows then.

--- Completion/Core/_expand.bak2        Wed Feb 16 10:58:09 2000
+++ Completion/Core/_expand     Wed Feb 16 10:58:18 2000
@@ -7,7 +7,7 @@
 # the expansions done produce no result or do not change the original
 # word from the line.
 
-local exp word="$PREFIX$SUFFIX" sort expr expl subd
+local exp word="$PREFIX$SUFFIX" sort expr expl subd suf=" "
 local curcontext="${curcontext/:[^:]#:/:expand:}"
 
 # First, see if we should insert all *completions*.
@@ -41,7 +41,7 @@
 zstyle -s ":completion:${curcontext}:" glob expr &&
     [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
     exp=( ${~exp}(N) )
- 
+
 # If we don't have any expansions or only one and that is the same
 # as the original string, we let other completers run.
 
@@ -60,16 +60,19 @@
 
 [[ "$sort" = (yes|true|1|on) ]] && exp=( "${(@o)exp}" )
 
+# If there is only one expansion, add a suitable suffix
+(($#exp == 1)) && suf='' && [[ -d $exp ]] && suf='/'  
+
 if [[ -z "$compstate[insert]" ]] ;then
   _description all-expansions expl 'all expansions' "o:$word"
 
-  compadd "$expl[@]" -UQ - "$exp"
+  compadd "$expl[@]" -UQ -qS "$suf" - "$exp"
 else
   _tags all-expansions expansions original
 
 
   _requested all-expansions expl 'all expansions' "o:$word" &&
-      compadd "$expl[@]" -UQ "$exp"
+      compadd "$expl[@]" -UQ -qS "$suf" - "$exp"
 
   if _requested expansions; then
     if [[ "$sort" = menu ]]; then



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