about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrey Borzenkov <bor@users.sourceforge.net>2009-01-09 20:54:35 +0000
committerAndrey Borzenkov <bor@users.sourceforge.net>2009-01-09 20:54:35 +0000
commit1a43616975310a638f76ba4f5e73757e4b071a1f (patch)
tree6f9fb10b571018ab8e3ba3d3af5286a18c2f098d
parent369a03d09f1661ea92509dde0e1c45fcc9620adb (diff)
downloadzsh-1a43616975310a638f76ba4f5e73757e4b071a1f.tar.gz
zsh-1a43616975310a638f76ba4f5e73757e4b071a1f.tar.xz
zsh-1a43616975310a638f76ba4f5e73757e4b071a1f.zip
26270: allow accept-and-menu-complete work with _vallues as well
-rw-r--r--ChangeLog9
-rw-r--r--Completion/Base/Utility/_values2
-rw-r--r--Src/Zle/compcore.c1
-rw-r--r--Src/Zle/complete.c4
-rw-r--r--Src/Zle/compresult.c24
5 files changed, 27 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f177cdb5..04f434765 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,13 @@
 
 2009-01-09  Andrey Borzenkov <bor@zsh.org>
 
+	* 26270: Completion/Base/Utility/_values, Doc/Zsh/compwid.yo,
+	Src/Zle/compcore.c, Src/Zle/complete.c, Src/Zle/compresult.c:
+	allow accept-and-menu-complete to work also with _values.
+	Add compstate[list_in_word] flag to control, whether suffix
+	is replaced by space; when set, next match is added in the same
+	word.
+
 	* unposted: Completion/Mandriva/Command/.distfiles,
 	Completion/Mandriva/Command/_rebootin: add _rebootin completion
 	from Mandriva RPM (modified to allow spaces in GRUB menu titles)
@@ -10879,5 +10886,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4499 $                         
+* $Revision: 1.4500 $                         
 *****************************************************
diff --git a/Completion/Base/Utility/_values b/Completion/Base/Utility/_values
index 52c42bc70..a478a8517 100644
--- a/Completion/Base/Utility/_values
+++ b/Completion/Base/Utility/_values
@@ -12,6 +12,8 @@ if compvalues -i "$@"; then
   local noargs args opts descr action expl sep argsep subc test='*'
   local oldcontext="$curcontext"
 
+  compstate[list_in_word]=1
+
   compvalues -S argsep
   compvalues -s sep && [[ -n "$sep" ]] && test="[^${(q)sep}]#"
 
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 529537d37..40c5f19ca 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -325,6 +325,7 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat)
     comppatinsert = ztrdup("menu");
     forcelist = 0;
     haspattern = 0;
+    complistinword = 0;
     complistmax = getiparam("LISTMAX");
     zsfree(complastprompt);
     complastprompt = ztrdup(((isset(ALWAYSLASTPROMPT) && zmult == 1) ||
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 6398fd3e7..7dbae1dee 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -38,6 +38,7 @@ zlong compcurrent,
       complistmax;
 /**/
 zlong complistlines,
+      complistinword,
       compignored;
 
 /**/
@@ -1146,6 +1147,7 @@ static struct compparam compkparams[] = {
       GSU(unambig_pos_gsu) },
     { "insert_positions", PM_SCALAR | PM_READONLY, NULL,
       GSU(insert_pos_gsu) },
+    { "list_in_word", PM_INTEGER, VAL(complistinword), NULL },
     { "list_max", PM_INTEGER, VAL(complistmax), NULL },
     { "last_prompt", PM_SCALAR, VAL(complastprompt), NULL },
     { "to_end", PM_SCALAR, VAL(comptoend), NULL },
@@ -1596,7 +1598,7 @@ setup_(UNUSED(Module m))
 	compvared = compqstack = NULL;
     complastprefix = ztrdup("");
     complastsuffix = ztrdup("");
-    complistmax = 0;
+    complistmax = complistinword = 0;
     hascompmod = 1;
 
     return 0;
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index e595802dd..630c7634c 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1309,21 +1309,23 @@ accept_last(void)
 	lastbrbeg->str[l] = ',';
 	lastbrbeg->str[l + 1] = '\0';
     } else {
-	int l;
-
 	zlemetacs = minfo.pos + minfo.len + minfo.insc;
-	iremovesuffix(' ', 1);
-	l = zlemetacs;
-	zlemetacs = minfo.pos + minfo.len + minfo.insc - (*(minfo.cur))->qisl;
-	if (zlemetacs < l)
-	    foredel(l - zlemetacs, CUT_RAW);
-	else if (zlemetacs > zlemetall)
-	    zlemetacs = zlemetall;
-	inststrlen(" ", 1, 1);
+	if (!complistinword) {
+	    int l;
+
+	    iremovesuffix(' ', 1);
+	    l = zlemetacs;
+	    zlemetacs = minfo.pos + minfo.len + minfo.insc - (*(minfo.cur))->qisl;
+	    if (zlemetacs < l)
+		foredel(l - zlemetacs, CUT_RAW);
+	    else if (zlemetacs > zlemetall)
+		zlemetacs = zlemetall;
+	    inststrlen(" ", 1, 1);
+	}
 	minfo.insc = minfo.len = 0;
 	minfo.pos = zlemetacs;
 	minfo.we = 1;
-    }
+	}
 
     if (!wasmeta)
 	unmetafy_line();