about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Commands/_next_tags28
-rw-r--r--Doc/Zsh/compwid.yo6
-rw-r--r--Src/Zle/compcore.c25
4 files changed, 48 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ff0526dc..f815b4b40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/Completion/Commands/_next_tags b/Completion/Commands/_next_tags
index 4861d1adf..867cf0b98 100644
--- a/Completion/Commands/_next_tags
+++ b/Completion/Commands/_next_tags
@@ -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}})(|:*)}"
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index 775ead546..a89c0cc16 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -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.
 )
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 3260ea11e..2a9ebbaa5 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -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"));