1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-18 15:21:16 +02:00

make _next_tags be usable with menu-completion

This commit is contained in:
Sven Wischnowsky 2000-04-04 11:26:26 +00:00
parent 4df3578148
commit 87b625f15f
4 changed files with 48 additions and 15 deletions

View file

@ -1,5 +1,9 @@
2000-04-03 Sven Wischnowsky <wischnow@informatik.hu-berlin.de> 2000-04-03 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
* 10459: Completion/Commands/_next_tags, Doc/Zsh/compwid.yo,
Src/Zle/compcore.c: _next_tags should be usable with menu-
completion
* 10456: Src/Zle/compcore.c: Copy QIPREFIX/QISUFFIX. * 10456: Src/Zle/compcore.c: Copy QIPREFIX/QISUFFIX.
2000-04-04 Andrew Main <zefram@zsh.org> 2000-04-04 Andrew Main <zefram@zsh.org>

View file

@ -3,7 +3,7 @@
# Main widget. # Main widget.
_next_tags() { _next_tags() {
local comp local comp ins
if [[ -z $compstate[old_list] ]]; then if [[ -z $compstate[old_list] ]]; then
comp=() comp=()
@ -17,12 +17,18 @@ _next_tags() {
_next_tags_pre="${LBUFFER%${PREFIX}}" _next_tags_pre="${LBUFFER%${PREFIX}}"
_next_tags_not="$_next_tags_not $_lastcomp[tags]" _next_tags_not="$_next_tags_not $_lastcomp[tags]"
if [[ -n "$compstate[old_insert]" ]]; then
PREFIX="$_lastcomp[prefix]"
SUFFIX="$_lastcomp[suffix]"
ins=1
fi
_main_complete "$comp[@]" _main_complete "$comp[@]"
[[ $compstate[insert] = automenu ]] && [[ $compstate[insert] = automenu ]] &&
compstate[insert]=automenu-unambiguous compstate[insert]=automenu-unambiguous
compstate[insert]='' compstate[insert]="$ins"
compstate[list]='list force' compstate[list]='list force'
compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) compprefuncs=( "$compprefuncs[@]" _next_tags_pre )
@ -36,10 +42,16 @@ _next_tags_pre() {
# I think one should still be able to edit the current word between # I think one should still be able to edit the current word between
# attempts to complete it. # attempts to complete it.
if [[ $_next_tags_pre != ${LBUFFER%${PREFIX}} ]]; then if [[ -n $compstate[old_insert] && $WIDGET != _next_tags ]]; then
compstate[old_list]=keep
compstate[insert]=menu:2
return 0
elif [[ ${LBUFFER%${PREFIX}} != ${_next_tags_pre}* ]]; then
unset _sort_tags unset _sort_tags
else else
compprefuncs=( "$compprefuncs[@]" _next_tags_pre ) compprefuncs=( "$compprefuncs[@]" _next_tags_pre )
[[ -n "$compstate[old_list]" && -n "$_next_tags_reset" ]] &&
_next_tags_not= _next_tags_reset=
fi fi
} }
@ -60,13 +72,13 @@ _next_tags_sort() {
if [[ $funcstack[4] = _files ]]; then if [[ $funcstack[4] = _files ]]; then
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
[[ "$tags" = *${${tmp[-1]##[^\\]:}%:*}* ]] && [[ "$tags" = *${${tmp[-1]##[^\\]:}%:*}* ]] &&
tags=( $order ) _next_tags_not= tags=( $order ) _next_tags_reset=yes
else else
[[ "$tags" = *all-files* ]] && tags=( $order ) _next_tags_not= [[ "$tags" = *all-files* ]] && tags=( $order ) _next_tags_reset=yes
fi fi
else else
[[ $#tags -ne $#order && "$tags" != *(${(j:|:)~argv})* ]] && [[ $#tags -ne $#order && "$tags" != *(${(j:|:)~argv})* ]] &&
tags=( $order ) _next_tags_not= tags=( $order ) _next_tags_reset=yes
fi fi
for tag in $tags; do for tag in $tags; do
case $tag in case $tag in
@ -80,9 +92,9 @@ _next_tags_sort() {
if [[ -z "$nodef" ]]; then if [[ -z "$nodef" ]]; then
if [[ $funcstack[4] = _files ]]; then if [[ $funcstack[4] = _files ]]; then
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
[[ "$argv" = *${${tmp[-1]##[^\\]:}%:*}* ]] && _next_tags_not= [[ "$argv" = *${${tmp[-1]##[^\\]:}%:*}* ]] && _next_tags_reset=yes
else else
[[ "$argv" = *all-files* ]] && _next_tags_not= [[ "$argv" = *all-files* ]] && _next_tags_reset=yes
fi fi
fi fi
comptry "${(@)argv:#(${(j:|:)~${=_next_tags_not}})(|:*)}" comptry "${(@)argv:#(${(j:|:)~${=_next_tags_not}})(|:*)}"

View file

@ -290,6 +290,12 @@ one more than the maximum selects the first. Unless the value of this
key ends in a space, the match is inserted as in a menu-completion, key ends in a space, the match is inserted as in a menu-completion,
i.e. without automatically appending a space. i.e. without automatically appending a space.
Both tt(menu) and tt(automenu) may also specify the the number of the
match to insert, given after a colon, optionally followed by a second
colon and a group number. For example, `tt(menu:2)' says to start
menu-completion, beginning with the second match and `tt(menu:3:2)'
says to start menu-completion with the third match in the second group.
It may also be set to tt(all), which makes all matches generated be It may also be set to tt(all), which makes all matches generated be
inserted into the line. inserted into the line.
) )

View file

@ -746,11 +746,6 @@ callcompfunc(char *s, char *fn)
!strcmp(compinsert, "unambiguous") || !strcmp(compinsert, "unambiguous") ||
!strcmp(compinsert, "automenu-unambiguous")) !strcmp(compinsert, "automenu-unambiguous"))
useline = 1, usemenu = 0; useline = 1, usemenu = 0;
else if (!strcmp(compinsert, "menu"))
useline = 1, usemenu = 1;
else if (!strcmp(compinsert, "auto") ||
!strcmp(compinsert, "automenu"))
useline = 1, usemenu = 2;
else if (!strcmp(compinsert, "all")) else if (!strcmp(compinsert, "all"))
useline = 2, usemenu = 0; useline = 2, usemenu = 0;
else if (idigit(*compinsert)) { else if (idigit(*compinsert)) {
@ -763,8 +758,24 @@ callcompfunc(char *s, char *fn)
insgnum = atoi(m + 1); insgnum = atoi(m + 1);
} }
insspace = (compinsert[strlen(compinsert) - 1] == ' '); insspace = (compinsert[strlen(compinsert) - 1] == ' ');
} else } else {
char *p;
if (strpfx("menu", compinsert))
useline = 1, usemenu = 1;
else if (strpfx("auto", compinsert))
useline = 1, usemenu = 2;
else
useline = usemenu = 0; useline = usemenu = 0;
if (useline && (p = strchr(compinsert, ':'))) {
insmnum = atoi(++p);
if ((p = strchr(p, ':'))) {
insgroup = 1;
insgnum = atoi(p + 1);
}
}
}
startauto = (compinsert && startauto = (compinsert &&
!strcmp(compinsert, "automenu-unambiguous")); !strcmp(compinsert, "automenu-unambiguous"));
useexact = (compexact && !strcmp(compexact, "accept")); useexact = (compexact && !strcmp(compexact, "accept"));