Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion or.. expansion..
- X-seq: zsh-users 4048
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Andrew Markebo <flognat@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Subject: Re: Completion or.. expansion..
- Date: Tue, 24 Jul 2001 18:00:12 -0700
- In-reply-to: <m3puaqt4dr.fsf@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <m3puaqt4dr.fsf@xxxxxxxxxxxxxxxxxxxxx>
On Jul 24, 11:16pm, Andrew Markebo wrote:
>
> I have one quick question.. It is speaking of completion and
> expansion.. differences..
>
> I suppose expansion is the one to use
They're each for a different purpose.
Expansion takes a symbolic reference -- a `$parameter' string, a globbing
pattern, etc. -- and replaces it with the actual string to which it refers
-- the value of the parameter, the list of files matching the glob, etc.
This operation is deterministic -- there's only one possible expansion (or
none).
Completion takes a string that represents a fragment of a (usually) longer
string and, based on the context in which that fragment appears, replaces
it with the longer string. In this case, however, there may be several
possible replacements, so zsh may have to ask the user to help it choose
one. There are a variety of "ask the user" methods to choose from.
If you use the `expand-or-complete' key binding, then zsh always tries to
expand first, and only completes if there is nothing to expand. If instead
you use the `complete-word' key binding, zsh never attempts expansion; but
you can configure the completion system to behave as if it does. (You can
probably work out what other key bindings do from their names.)
If you configure the completion system to use expansion, then you can get
several effects: Either it can immediately use the deterministic result,
as if real expansion were happening; or, if the result of expansion is more
than one word (e.g. globbing), then it can treat those words as possible
completions and ask you to choose one of them. That latter is what happens
when you use the `glob_complete' option. Or it's even possible to set it
up to do both of those things -- that is, offer the full expansion as one
of the completions, along with each of the individual words, and ask what
you intended for it to do.
> Meanwhile, the options like
>
> setopt glob bareglobqual nullglob rcexpandparam extendedglob unset
> unsetopt markdirs globsubst shwordsplit shglob ksharrays cshnullglob
> unsetopt allexport
>
> Should I use these, or do something with completion, compinstall?
Where did you find those three (un)setopt commands, and why do you think
you need them?
Whether you use those options is a separate issue from whether you use the
completion system or whether you use compinstall to configure it. The
completion system will do its own appropriate setopts when it needs to,
and then restore yours when it is finished. So you should choose options
because they provide the behavior you want when using the other features
of the shell -- unless the description of the option in the manual says
explicitly that it is used in "completion" or "listing", and even then
the options will often apply mostly to old-style `compctl' completions.
Configuring the new-style completions is mostly via `zstyle' commands.
Yes, you probably should run compinstall to set up the completion system
for yourself for the first time. It will create appropriate zstyles for
you and add them to your initialization files.
Enjoy.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author