From: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>
To: <zsh-workers@sunsite.auc.dk>
Cc: "E. Jay Berkenbilt" <ejb@ql.org>
Subject: PATCH: _insert_all_matches bindable command
Date: Wed, 20 Sep 2000 15:08:32 +0400 [thread overview]
Message-ID: <001901c022f3$1cf94770$21c9ca95@mow.siemens.ru> (raw)
In-Reply-To: <1000919021428.ZM30137@candle.brasslantern.com>
[Moved to zsh-workers]
> }
> } Well, in fact, I never do this with rmdir. [...]
> } I really use this with cvs add and cvs rm where it is great.
>
> So you have it restricted by style to :completion::complete:cvs* or
> something like that? I could see where that would be useful, but I
> wouldn't want it in context :completion:* ...
>
Yes, exactly. It is very unlikely that somebody would like to *always* insert
all matches even for any particular command. For this reason I also never used
_expand *completer*. Trying expansion on every completion just seems too
general. (There is one more reason - IMHO expansion is context-independent
operation while normal completion is highly context-dependent. You just cannot
mix both).
For this reason here the proposed patch, that adds _insert_all_matches widget
bound to ^Xi. It can be used after any completion and standalone. It will
reuse existing list if available (controlled by old-list style, like in
_oldlist completer). Called standalone it will call normal completion and
insert all generated matches.
Some comments:
- it will reuse any exisitng list even if it's not appropriate. E.g. in case
of correction original word is listed as possible match, so ^Xi will insert it
as well. Another similar case is _expand. But in case of _expand you already
have the choice to insert all expansions.
- I could not find a way to supress suffix addition. It is weird as it is
added only to the last match anyway. Sven?
- it does not work inside of menu selection, because it accepts selected match
and clears list even before calling any widget. It does work in menu
completion. Sven will have the final word, but, may be, menu selection should
not accept the match and clear list at least for completion widgets. Also,
there is subtle difference between menu completion and menu selection - menu
selection adds space where menu completion does not. E.g.:
bor@itsrm2% l f*
fOo foO foo
(selection)
bor@itsrm2% l fOo
Completing file
fOo foO foo
(press `i')
bor@itsrm2% l fOo i
Completing file
fOo foO foo
(completion)
bor@itsrm2% ls fOo
Completing file
fOo foO foo
(press `i')
bor@itsrm2% ls fOoi
Completing file
fOo foO foo
I would really prefer the same behaviour in both cases.
Jay, would it be useful to you?
-andrej
sourceforge CVS server is down, so I just send the function itself (without
manual update). Coments?
====== cut here ======
#compdef -K _insert_all_matches complete-word \C-xi
setopt localoptions nullglob rcexpandparam extendedglob noshglob
unsetopt markdirs globsubst shwordsplit nounset ksharrays
local oldcurcontext="$curcontext" list ret
if [[ -z "$oldcurcontext" ]]; then
curcontext="insert-all-matches:::"
else
curcontext="insert-all-matches:${oldcurcontext#*:}"
fi
zstyle -s ":completion:${curcontext}:" old-list list
# If there is already an old list,
# and either the style :insert-all-matches:old-list is `always',
# or it is not `never', then insert the existing list
# (even if it was generated by another widget).
# Else just call completion and insert whatever matches it generated
# TODO: does not work in menu selection
if [[ -n $compstate[old_list] && $list != never &&
$LASTWIDGET != _complete_help && $WIDGET != _complete_help ]]; then
compstate[old_list]=keep
compstate[insert]=all
return 0
else
curcontext="$oldcurcontext"
_main_complete
ret=$?
compstate[insert]=all
return $ret
fi
next parent reply other threads:[~2000-09-20 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1000919021428.ZM30137@candle.brasslantern.com>
2000-09-20 11:08 ` Andrej Borsenkow [this message]
2000-09-22 15:13 ` Bart Schaefer
2000-09-22 15:47 ` Suffixes and menu completion vs. menu selection Bart Schaefer
2000-10-04 11:28 PATCH: _insert_all_matches bindable command Sven Wischnowsky
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='001901c022f3$1cf94770$21c9ca95@mow.siemens.ru' \
--to=andrej.borsenkow@mow.siemens.ru \
--cc=ejb@ql.org \
--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).