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

PATCH: Re: expansion



Sven wrote:
> We were discussing these... This adds the style `suffix' and makes
> `accept-exact' be used by _expand:

> Ok. Is this good enough? Oliver?

This is a lot better. Thanks Sven.

There was one minor problem though.

> - With `suffix', expansion is not done if there is anything after a
>   `~foo' or `$foo'. I.e. it will not expand `~foo/<TAB>', but it will
>   expand `~foo'.

This doesn't work with arrays: they are never expanded. If I do
cd $fpath[17]<tab> the directory from my fpath should be expanded. I
have fixed this in the patch below.

With `suffix', variables mixed with globs (e.g $f/*<tab>) will not do
glob expansion. This will not bother me a huge amount because I just
have to remember to expand the variable before I put the glob part in
but I'll maybe look at extending subst-globs-only to handle this
situation as well.

Other people may want more control over when $( ... ) and math stuff is
expanded (such as the suffix style functionality). I wouldn't for the
$( ... ) stuff because we can't guarantee that the command produces the
same output always so completion can't continue after one without
expansion. I don't use $(( ... )) often enough to really care whether it
expands though I'd probably prefer the suffix style behaviour.

I'm now back to using _expand so I may come across other issues which I
haven't thought of at the moment. I'll let you know if I think of
anything.

>   We were using rexexact in the old expansion code, so I thought we
>   should just use `accept-exact' which is the style equivalent of
>   recexact.
>   Note that I've used the same default value in _expand as it has
>   elsewhere (`false'), which means that without further configuring,
>   this now behaves differently. Should we make it default to `true' in 
>   _expand?

Wouldn't it maybe be a good idea if the value of the recexact option
was used to determine the default for accept-exact so by just setting
the option, it would have an effect throughout the new completion
system. There would then always be the option of setting it to a
different value for a context with zstyle. I would also be inclined to
rename the style to recexact and negate its meaning for consistency
with the option.

I've never been convinced that it is wise that without any styles set,
_expand effectively does nothing: it will inevitably be the source of
an FAQ. I would have thought that it would be best if by default it
behaves in the way which most closely resembles expand-or-complete: so
I would set suffix, glob and substitute by default.

I also agree with Sven in not being too happy about having different
defaults depending on whether _expand was used as a completer or called
from _expand_word as suggested by Bart.

Oliver

Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.16
diff -u -r1.16 _expand
--- Completion/Core/_expand     2000/06/13 11:26:08     1.16
+++ Completion/Core/_expand     2000/06/14 16:03:07
@@ -35,7 +35,7 @@
 fi

 zstyle -t ":completion:${curcontext}:" suffix &&
-  [[ "$word" = (\~*/*|\$[a-zA-Z0-9_]##[^a-zA-Z0-9_]*|\$\{*\}?*) ]] &&
+  [[ "$word" = (\~*/*|\$[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]*|\$\{*\}?*) ]] &&
   return 1

 zstyle -t ":completion:${curcontext}:" accept-exact ||



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