From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: _path_files and the -M option
Date: Sun, 27 Feb 2000 20:41:46 +0000 [thread overview]
Message-ID: <1000227204146.ZM27900@candle.brasslantern.com> (raw)
I was experimenting with using match specs as documented in PWS's guide
(section 6.7) and made up this little function:
function _test { _files -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' }
You may recognize that -M as the one from the example setopts completion.
So what I'm trying to accomplish -- for no reason other than to play with
it -- is to complete file names after an optional "no" prefix, with case
and underscores ignored.
Unfortunately, it doesn't work.
Everything is fine up to through the point where _path_files calls
compadd -D tmp1 -F _comp_ignore -M "L:|[nN][oO]= M:_= M:{A-Z}={a-z}" - ...
(somewhere between lines 300 and 310 in my current copy of _path_files,
the line numbers reported by xtrace appear to be somewhat off).
This correctly leaves the right set of matches in tmp1, but doesn't
actually add the matches yet. That happens down after line 440 or so,
after "if (( tmp4 ))" is tested, and the actual compadd is:
compadd -Qf -J -default- -F _comp_ignore -p '' -W '' -M "r:|/=* r:|=*" - ...
where the "..." is still the intended set of matches.
But none of those actually match what's on the line; the "L:|..." has
been lost, so (AFAICT) the presence of "no" on the line causes them all
to be discarded.
The following patch causes it to work by preserving the passed-in match
specs on *every* call to compadd, simply appending the one _path_files
supplied itself, but I'm not sure what else this might break.
Please don't apply this patch until Sven chimes in. Sven?
Index: Completion/Core/_path_files
===================================================================
@@ -458,26 +458,26 @@
if [[ "$tmp3" = */* ]]; then
compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \
-W "$prepath$realpath$testpath" \
- "$pfxsfx[@]" -M "r:|/=* r:|=*" \
+ "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \
- "${(@)tmp1%%/*}"
else
compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \
-W "$prepath$realpath$testpath" \
- "$pfxsfx[@]" -M "r:|/=* r:|=*" \
+ "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \
- "$tmp1[@]"
fi
else
if [[ "$tmp3" = */* ]]; then
atmp=( -Qf "$mopts[@]" -p "$linepath$tmp2"
-W "$prepath$realpath$testpath"
- "$pfxsfx[@]" -M "r:|/=* r:|=*" )
+ "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" )
for i in "$tmp1[@]"; do
compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}"
done
else
compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \
-W "$prepath$realpath$testpath" \
- "$pfxsfx[@]" -M "r:|/=* r:|=*" \
+ "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \
- "$tmp1[@]"
fi
fi
@@ -525,7 +525,7 @@
tmp4="$testpath"
compquote tmp4 tmp1
compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \
- "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]"
+ "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" - "$tmp1[@]"
fi
done
@@ -541,7 +541,7 @@
if (( $#exppaths )); then
PREFIX="${opre}"
SUFFIX="${osuf}"
- compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]"
+ compadd -Q "$mopts[@]" -S '' "$matcher[@]" "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]"
fi
fi
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
reply other threads:[~2000-02-27 20:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1000227204146.ZM27900@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/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).