mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-05 11:01:13 +02:00
make _next_tags be usable with menu-completion
This commit is contained in:
parent
4df3578148
commit
87b625f15f
4 changed files with 48 additions and 15 deletions
|
@ -1,5 +1,9 @@
|
|||
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.
|
||||
|
||||
2000-04-04 Andrew Main <zefram@zsh.org>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Main widget.
|
||||
|
||||
_next_tags() {
|
||||
local comp
|
||||
local comp ins
|
||||
|
||||
if [[ -z $compstate[old_list] ]]; then
|
||||
comp=()
|
||||
|
@ -17,12 +17,18 @@ _next_tags() {
|
|||
_next_tags_pre="${LBUFFER%${PREFIX}}"
|
||||
_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[@]"
|
||||
|
||||
[[ $compstate[insert] = automenu ]] &&
|
||||
compstate[insert]=automenu-unambiguous
|
||||
|
||||
compstate[insert]=''
|
||||
compstate[insert]="$ins"
|
||||
compstate[list]='list force'
|
||||
|
||||
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
|
||||
# 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
|
||||
else
|
||||
compprefuncs=( "$compprefuncs[@]" _next_tags_pre )
|
||||
[[ -n "$compstate[old_list]" && -n "$_next_tags_reset" ]] &&
|
||||
_next_tags_not= _next_tags_reset=
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -60,13 +72,13 @@ _next_tags_sort() {
|
|||
if [[ $funcstack[4] = _files ]]; then
|
||||
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
|
||||
[[ "$tags" = *${${tmp[-1]##[^\\]:}%:*}* ]] &&
|
||||
tags=( $order ) _next_tags_not=
|
||||
tags=( $order ) _next_tags_reset=yes
|
||||
else
|
||||
[[ "$tags" = *all-files* ]] && tags=( $order ) _next_tags_not=
|
||||
[[ "$tags" = *all-files* ]] && tags=( $order ) _next_tags_reset=yes
|
||||
fi
|
||||
else
|
||||
[[ $#tags -ne $#order && "$tags" != *(${(j:|:)~argv})* ]] &&
|
||||
tags=( $order ) _next_tags_not=
|
||||
tags=( $order ) _next_tags_reset=yes
|
||||
fi
|
||||
for tag in $tags; do
|
||||
case $tag in
|
||||
|
@ -80,9 +92,9 @@ _next_tags_sort() {
|
|||
if [[ -z "$nodef" ]]; then
|
||||
if [[ $funcstack[4] = _files ]]; then
|
||||
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
|
||||
[[ "$argv" = *${${tmp[-1]##[^\\]:}%:*}* ]] && _next_tags_not=
|
||||
[[ "$argv" = *${${tmp[-1]##[^\\]:}%:*}* ]] && _next_tags_reset=yes
|
||||
else
|
||||
[[ "$argv" = *all-files* ]] && _next_tags_not=
|
||||
[[ "$argv" = *all-files* ]] && _next_tags_reset=yes
|
||||
fi
|
||||
fi
|
||||
comptry "${(@)argv:#(${(j:|:)~${=_next_tags_not}})(|:*)}"
|
||||
|
|
|
@ -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,
|
||||
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
|
||||
inserted into the line.
|
||||
)
|
||||
|
|
|
@ -746,11 +746,6 @@ callcompfunc(char *s, char *fn)
|
|||
!strcmp(compinsert, "unambiguous") ||
|
||||
!strcmp(compinsert, "automenu-unambiguous"))
|
||||
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"))
|
||||
useline = 2, usemenu = 0;
|
||||
else if (idigit(*compinsert)) {
|
||||
|
@ -763,8 +758,24 @@ callcompfunc(char *s, char *fn)
|
|||
insgnum = atoi(m + 1);
|
||||
}
|
||||
insspace = (compinsert[strlen(compinsert) - 1] == ' ');
|
||||
} else
|
||||
useline = usemenu = 0;
|
||||
} else {
|
||||
char *p;
|
||||
|
||||
if (strpfx("menu", compinsert))
|
||||
useline = 1, usemenu = 1;
|
||||
else if (strpfx("auto", compinsert))
|
||||
useline = 1, usemenu = 2;
|
||||
else
|
||||
useline = usemenu = 0;
|
||||
|
||||
if (useline && (p = strchr(compinsert, ':'))) {
|
||||
insmnum = atoi(++p);
|
||||
if ((p = strchr(p, ':'))) {
|
||||
insgroup = 1;
|
||||
insgnum = atoi(p + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
startauto = (compinsert &&
|
||||
!strcmp(compinsert, "automenu-unambiguous"));
|
||||
useexact = (compexact && !strcmp(compexact, "accept"));
|
||||
|
|
Loading…
Reference in a new issue