zsh-users
 help / color / mirror / code / Atom feed
* Completion or.. expansion..
@ 2001-07-24 21:16 Andrew Markebo
  2001-07-25  1:00 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Markebo @ 2001-07-24 21:16 UTC (permalink / raw)
  To: zsh-users

I am throwing a couple of eyes at the zshguide, probably too fast, but
I have one quick question.. It is speaking of completion and
expansion.. differences.. 

I suppose expansion is the one to use, know when I am getting started
with 4.0.2 and no (very little) history to keep.. 

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?

        /Andy


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Completion or.. expansion..
  2001-07-24 21:16 Completion or.. expansion Andrew Markebo
@ 2001-07-25  1:00 ` Bart Schaefer
  2001-07-25  7:23   ` Andrew Markebo
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2001-07-25  1:00 UTC (permalink / raw)
  To: Andrew Markebo, zsh-users

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   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Completion or.. expansion..
  2001-07-25  1:00 ` Bart Schaefer
@ 2001-07-25  7:23   ` Andrew Markebo
  2001-07-25  8:27     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Markebo @ 2001-07-25  7:23 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

/ "Bart Schaefer" <schaefer@candle.brasslantern.com> wrote:
| 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.

Hmm ok, then.. time to reformulate the question.. I want to configure
what TAB does :-) I assume that is Completion then. 

The main confusion was when quickly (yeah I know, I should take my
time..) reading through chapter 6 of the zshguide "Completion and
expansion",

| > 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?

Just an example from my side, sort of "is it these I should poke
on?" (from the zsh users guide) or are they replaced by 
        "zstyle ':completion:*' completer _list ..."
or do they work together? If I have got stuff right, the zstyle
replaces them?


| 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.

So basically.. remove all my options for completion, run compinstall
and live happily for the rest of the time :-)?

Thank you !

        /Andy


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Completion or.. expansion..
  2001-07-25  7:23   ` Andrew Markebo
@ 2001-07-25  8:27     ` Bart Schaefer
  2001-07-25  8:34       ` Sven Wischnowsky
  2001-07-25  9:32       ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Schaefer @ 2001-07-25  8:27 UTC (permalink / raw)
  To: Andrew Markebo; +Cc: zsh-users

On Jul 25,  9:23am, Andrew Markebo wrote:
} Subject: Re: Completion or.. expansion..
}
} Hmm ok, then.. time to reformulate the question.. I want to configure
} what TAB does :-) I assume that is Completion then. 

Hmm, ok, then, time to reformulate the answer.

bindkey '\t' expand-or-complete	# Does expansion first, or else completion
bindkey '\t' complete-word	# Does completion only

The default binding if you don't re-bindkey it is expand-or-complete.

If you put the word "_expand" anywhere in your completer zstyle, though,
the `compinit' function (a call to which is added to your ~/.zshrc by
`compinstall') will automatically rebind '\t' from expand-or-complete
to complete-word.

So the upshot probably is that you don't need to worry about it at all.
Just leave it alone, run compinstall, and the right things will happen.

} | > 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?
} 
} Just an example from my side, sort of "is it these I should poke
} on?" (from the zsh users guide) or are they replaced by 
}         "zstyle ':completion:*' completer _list ..."
} or do they work together? If I have got stuff right, the zstyle
} replaces them?

None of those setopts has anything whatsoever to do with completion, with
the possible exception of `markdirs'.  So no, the zstyles don't replace
*those* options, but there *are* some *other* options that zstyles either
replace or augment.

That's why I ask, "Where did you find *those* commands, and why ...?"

} So basically.. remove all my options for completion, run compinstall
} and live happily for the rest of the time :-)?

More likely, it's leave all your options exactly as they are, run
compinstall, and live happily.

-- 
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   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Completion or.. expansion..
  2001-07-25  8:27     ` Bart Schaefer
@ 2001-07-25  8:34       ` Sven Wischnowsky
  2001-07-25  9:32       ` Peter Stephenson
  1 sibling, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2001-07-25  8:34 UTC (permalink / raw)
  To: zsh-users

Bart Schaefer wrote:

> ...
> 
> More likely, it's leave all your options exactly as they are, run
> compinstall, and live happily.

And later, when you want to play or feel adventurous, read the section
on configuration try some of the styles and options (the same holds for
non-completion options).


Bye
  Sven


-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Completion or.. expansion..
  2001-07-25  8:27     ` Bart Schaefer
  2001-07-25  8:34       ` Sven Wischnowsky
@ 2001-07-25  9:32       ` Peter Stephenson
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2001-07-25  9:32 UTC (permalink / raw)
  To: Zsh users list, Andrew Markebo

"Bart Schaefer" wrote:
> } | > setopt glob bareglobqual nullglob rcexpandparam extendedglob unset
> } | >   unsetopt markdirs globsubst shwordsplit shglob ksharrays cshnullglob
> } | >   unsetopt allexport
> 
> That's why I ask, "Where did you find *those* commands, and why ...?"

See section 6.4 of the guide.  These are the options it describes as being
in (or out of) effect *inside* function widgets. It's a little bit out of
date; the complete list (all but the first two defined in the array
_comp_options) is now

  localoptions localtraps glob bareglobqual nullglob rcexpandparam
  extendedglob unset
  NO_markdirs NO_globsubst NO_shwordsplit NO_shglob NO_kshglob
  NO_ksharrays NO_cshnullglob NO_allexport NO_aliases NO_errexit

So they're only relevant when you start to write your own functions for
completion.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-07-25  9:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-24 21:16 Completion or.. expansion Andrew Markebo
2001-07-25  1:00 ` Bart Schaefer
2001-07-25  7:23   ` Andrew Markebo
2001-07-25  8:27     ` Bart Schaefer
2001-07-25  8:34       ` Sven Wischnowsky
2001-07-25  9:32       ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).