summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-09 11:04:44 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-09 11:04:44 +0000
commit8c6a5af791ea0ccf44b71577b4cb1a9cec92646c (patch)
treeac410f43b25caababd99f5b4987aeb7d2d66ccac /Src
parent8a5fb55595d730a0e1fc3a15ff5f69c58e9bdb5b (diff)
downloadzsh-8c6a5af791ea0ccf44b71577b4cb1a9cec92646c.tar.gz
zsh-8c6a5af791ea0ccf44b71577b4cb1a9cec92646c.tar.xz
zsh-8c6a5af791ea0ccf44b71577b4cb1a9cec92646c.zip
give control over insertion of tab when no non-blank character before cursor; add insert-tab style (11274)
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/compcore.c15
-rw-r--r--Src/Zle/zle_tricky.c11
2 files changed, 22 insertions, 4 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index e04973b0a..941023769 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -292,7 +292,7 @@ do_completion(Hookdef dummy, Compldat dat)
 	compqstack[0] = '\'';
 
     hasunqu = 0;
-    useline = (lst != COMP_LIST_COMPLETE);
+    useline = (wouldinstab ? -1 : (lst != COMP_LIST_COMPLETE));
     useexact = isset(RECEXACT);
     zsfree(compexactstr);
     compexactstr = ztrdup("");
@@ -334,6 +334,8 @@ do_completion(Hookdef dummy, Compldat dat)
 	clearlist = 1;
 	ret = 1;
 	minfo.cur = NULL;
+	if (useline < 0)
+	    selfinsert(zlenoargs);
 	goto compend;
     }
     zsfree(lastprebr);
@@ -342,7 +344,9 @@ do_completion(Hookdef dummy, Compldat dat)
 
     if (comppatmatch && *comppatmatch && comppatmatch != opm)
 	haspattern = 1;
-    if (!useline && uselist) {
+    if (useline < 0)
+	selfinsert(zlenoargs);
+    else if (!useline && uselist) {
 	/* All this and the guy only wants to see the list, sigh. */
 	cs = 0;
 	foredel(ll);
@@ -430,7 +434,7 @@ do_completion(Hookdef dummy, Compldat dat)
     /* Print the explanation strings if needed. */
     if (!showinglist && validlist && usemenu != 2 && 
 	(nmatches != 1 || diffmatches) &&
-	useline != 2 && (!oldlist || !listshown)) {
+	useline >= 0 && useline != 2 && (!oldlist || !listshown)) {
 	onlyexpl = 1;
 	showinglist = -2;
     }
@@ -706,7 +710,8 @@ callcompfunc(char *s, char *fn)
 	    compinsert = "";
 	    kset &= ~CP_INSERT;
 	}
-	compinsert = ztrdup(compinsert);
+	compinsert = (useline < 0 ? tricat("tab ", "", compinsert) :
+		      ztrdup(compinsert));
 	if (useexact)
 	    compexact = ztrdup("accept");
 	else {
@@ -780,6 +785,8 @@ callcompfunc(char *s, char *fn)
 
 	if (!compinsert)
 	    useline = 0;
+	else if (strstr(compinsert, "tab"))
+	    useline = -1;
 	else if (!strcmp(compinsert, "unambig") ||
 		 !strcmp(compinsert, "unambiguous") ||
 		 !strcmp(compinsert, "automenu-unambiguous"))
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index cb5770452..8accf52fb 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -77,6 +77,11 @@ mod_export int offs;
 /**/
 mod_export int usemenu, useglob;
 
+/* != 0 if we would insert a TAB if we weren't calling a completion widget. */
+
+/**/
+mod_export int wouldinstab;
+
 /* != 0 if we are in the middle of a menu completion. May be == 2 to force *
  * menu completion even if using different widgets.                        */
 
@@ -153,9 +158,15 @@ usetab(void)
 {
     unsigned char *s = line + cs - 1;
 
+    wouldinstab = 0;
     for (; s >= line && *s != '\n'; s--)
 	if (*s != '\t' && *s != ' ')
 	    return 0;
+    if (compfunc) {
+	wouldinstab = 1;
+
+	return 0;
+    }
     return 1;
 }