From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: [zash-3.0.0] bug in cdmatch for dirs w/ embedded space?
Date: Fri, 13 Sep 1996 09:50:49 +0200 [thread overview]
Message-ID: <199609130750.JAA06341@hydra.ifh.de> (raw)
In-Reply-To: ""alain (a.) caron""'s message of "Thu, 12 Sep 1996 15:38:00 MET." <"9653 Thu Sep 12 18:01:31 1996"@bnr.ca>
"alain (a.) caron" wrote:
> >reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t:gs/ /\\\\ /) )
>
> replace this last line by:
>
> reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t) )
Yes, this works. However, this version of cdmatch has the (for me at
least) critical limitation that it doesn't handle subdirectories, just
the first one below the directory in $cdpath. I've gone back to a
previous version of cdmatch and applied the same treatment, which
works there too, so the following is what I'm using at the moment.
Sorry, I can't remember who wrote this one originally.
The compctl instructions at the top of the other one still apply,
though I find it simpler to see if ordinary completion will find a
directory, and only then use cdmatch:
compctl -g '*(-/)' + -K cdmatch -S / -q cd pushd
###############################################################################
# cdmatch - directory matching for cd
#
# Save in your functions directory and autoload, then do
# compctl -K cdmatch -S / -q + -g '*(D-/)' cd pushd
#
# Completes directories using cdpath (as cd does). . is automatically
# included, because cd works that way.
#
# If an absolute path is being specified, or cdpath is blank, the completion is
# left up to the shell. This results in such completions having a different
# look from those done by cdmatch itself. Hopefully a future version of zsh
# will rectify this in some way.
local notonlydot npos args pref dir d
reply=()
# check for cdpath empty or only containing .
for dir in $cdpath; do [[ $dir != . ]] && notonlydot=1; done
if [[ $notonlydot != 1 ]]; then return; fi
# get word on which completion is requested
read -nc npos
read -Ac args
# check for absolute path - watch out for erroneous ~ expansion
pref=x$args[$npos]
if [[ $pref[2] = [/\~] ]]; then return; fi
# relative path - use cdpath
pref=$args[$npos]
for dir in . $cdpath; do
for d in $dir/$pref*(ND-/:s,$dir/,,); do
reply=( $reply ${d%%/#} )
done
done
return
###############################################################################
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
next prev parent reply other threads:[~1996-09-13 8:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-09-12 19:38 alain (a.) caron
1996-09-13 7:50 ` Peter Stephenson [this message]
-- strict thread matches above, loose matches on Subject: below --
1996-09-12 17:42 [zash-3.0.0] " Mark Borges
1996-09-12 19:38 ` Zefram
1996-09-12 20:22 ` Mark Borges
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199609130750.JAA06341@hydra.ifh.de \
--to=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).