head	2.2;
access;
symbols
	3_0_1:2.2
	3_0_0:2.1
	3_0-pre6:2.1
	3_0-pre5:2.0
	3_0-pre4:2.0
	beta15:1.2
	beta14:1.2
	beta13:1.2
	beta12:1.2
	beta11:1.2
	beta10:1.2
	3_0-pre3:2.0
	3_0-pre2:2.0
	3_0-pre1:2.0
	beta21:2.0
	beta20:2.0
	beta19:2.0
	beta18:2.0
	beta17:2.0
	beta16:2.0;
locks;
comment	@# @;


2.2
date	96.10.06.12.21.08;	author hzoli;	state Exp;
branches;
next	2.1;

2.1
date	96.08.02.19.33.13;	author hzoli;	state Exp;
branches;
next	2.0;

2.0
date	96.05.02.22.57.04;	author hzoli;	state Exp;
branches;
next	1.2;

1.2
date	95.02.10.02.00.18;	author coleman;	state Exp;
branches;
next	1.1;

1.1
date	94.11.08.07.01.18;	author zsh;	state Exp;
branches;
next	;


desc
@@


2.2
log
@add emulate -R zsh to some function examples.  From Bart (2172)
@
text
@# multicomp() {
# Completes all manner of files given prefixes for each path segment.
# e.g. s/z/s -> src/zsh-2.4/src
#
# Usage: e.g.
# compctl -D -f + -U -K multicomp
#
# Note that exactly matched directories are not expanded, e.g.
# s/zsh-2.4/s<TAB> will not expand to src/zsh-2.4old/src.
# Will expand glob patterns already in the word, but use complete-word,
# not TAB (expand-or-complete), or you will get ordinary glob expansion.
# Requires the -U option to compctl.
# Menucompletion is highly recommended for ambiguous matches.
# Liable to screw up escaped metacharacters royally.
# $fignore is not used: feel free to add your own bit.

emulate -R zsh				# Requires zsh 3.0-pre4 or later
local pref head sofar origtop newtop globdir="(-/)" wild
setopt localoptions nullglob rcexpandparam globdots
unsetopt markdirs globsubst shwordsplit nounset

pref="${1}$2"
# Hack to allow programmable completion to select multicomp after a :
# (e.g.
# compctl -D -f -x 's[:]' -U -K multicomp
# )
pref="${pref#:}"

sofar=('')
reply=('')

if [[ "$pref" = \~* ]]; then
  # If the string started with ~, save the head and what it will become.
  origtop="${pref%%/*}"
  newtop=${~origtop}
  # Save the expansion as the bit matched already
  sofar=($newtop)
  pref="${pref#$origtop}"
fi

while [[ -n "$pref" ]]; do
  [[ "$pref" = /* ]] && sofar=(${sofar}/) && pref="${pref#/}"
  head="${pref%%/*}"
  pref="${pref#$head}"
  if [[ -n "$pref" && -z $sofar[2] && -d "${sofar}$head" ]]; then
    # Exactly matched directory: don't try to glob
    reply=("${sofar}$head")
  else
    [[ -z "$pref" ]] && globdir=
    # if path segment contains wildcards, don't add another.
    if [[ "$head" = *[\*\?]* ]]; then
      wild=
    else
      wild='*'
    fi
    reply=(${sofar}"${head}${wild}${globdir}")
    reply=(${~reply})
  fi

  [[ -z $reply[1] ]] && reply=() && break
  [[ -n $pref ]] && sofar=($reply)
done

# Restore ~'s in front if there were any.
# There had better not be anything funny in $newtop.
[[ -n "$origtop" ]] && reply=("$origtop"${reply#$newtop})

# }

@


2.1
log
@unset nounset (in other words set unset) in the function
@
text
@d17 1
@


2.0
log
@New maintainer: Zoltn Hidvgi <hzoli@@cs.elte.hu>
@
text
@d19 1
a19 1
unsetopt markdirs globsubst shwordsplit
@


1.2
log
@*** empty log message ***
@
text
@@


1.1
log
@Initial revision
@
text
@d17 3
a19 1
local pref head rceptrue ngtrue sofar origtop newtop globdir="(-/)" wild
d21 1
a21 9
# No point using the toggle for rcexpandparam,
# since we don't know if the option is set already.
# (This is always the case, so what's the point in the toggle?)
# This stuff is going to be superceded by `setopt localopts' eventually.
[[ -o rcexpandparam ]] && rceptrue=1
[[ -o nullglob ]] && ngtrue=1
setopt rcexpandparam nullglob

pref=${1}$2
d26 1
a26 1
[[ $pref = :* ]] && pref=$pref[2,-1]
d31 1
a31 1
if [[ $pref[1] = '~' ]]; then
d33 1
a33 3
  origtop=${pref%%/*}
  [[ $origtop = */ ]] && origtop[-1]=
  # Next line assumes cshjunkietilde was not set.  See note on toggles above.
d37 1
a37 1
  pref=$pref[$#origtop+1,-1]
d40 5
a44 6
while [[ -n $pref ]]; do
  [[ $pref = /* ]] && sofar=(${sofar}/) && pref=$pref[2,-1]
  head=${pref%%/*}
  [[ $head = */ ]] && head[-1]=
  pref=$pref[$#head+1,-1]
  if [[ $pref = /* && -z $sofar[2] && -d ${sofar}$head ]]; then
d48 1
a48 1
    [[ $pref = /* ]] || globdir=
d50 1
a50 1
    if [[ $head = *[\*\?]* ]]; then
a54 2
    # $sofar must be expanded with rcexpandparam here, in such a way
    # that metacharacters are expanded in the eval step.
d56 1
a56 1
    eval "reply=($reply)"
d65 1
a65 1
[[ -n $origtop ]] && eval "reply=(\$reply:gs?$newtop?\\$origtop?)"
d67 1
a67 2
[[ rceptrue = 1 ]] || unsetopt rcexpandparam
[[ ngtrue = 1 ]] || unsetopt nullglob
a68 1
# }
@
