about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-13 10:45:28 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-13 10:45:28 +0000
commita4ed24438b36698761634591bb2eb397260ca2c3 (patch)
tree785c3104e80ad80b01c670e76646d90c1ca6c5f1 /Src/Zle
parent7eb928e2663197d52898b55cd2ccbe10c3222236 (diff)
downloadzsh-a4ed24438b36698761634591bb2eb397260ca2c3.tar.gz
zsh-a4ed24438b36698761634591bb2eb397260ca2c3.tar.xz
zsh-a4ed24438b36698761634591bb2eb397260ca2c3.zip
zsh-workers/7798
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/comp.h7
-rw-r--r--Src/Zle/compctl.c3
-rw-r--r--Src/Zle/zle_tricky.c31
3 files changed, 29 insertions, 12 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index ab8d62c8a..034410f3a 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -226,9 +226,10 @@ struct cmatch {
 
 #define CMF_FILE     1		/* this is a file */
 #define CMF_REMOVE   2		/* remove the suffix */
-#define CMF_PARBR    4		/* paramter expansion with a brace */
-#define CMF_PARNEST  8		/* nested paramter expansion */
-#define CMF_NOLIST  16		/* should not be listed */
+#define CMF_ISPAR    4		/* is paramter expansion */
+#define CMF_PARBR    8		/* paramter expansion with a brace */
+#define CMF_PARNEST 16		/* nested paramter expansion */
+#define CMF_NOLIST  32		/* should not be listed */
 
 
 /* Stuff for completion matcher control. */
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index 92e0b4e25..942a289f6 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -1751,6 +1751,9 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 	    case 'f':
 		dat.flags |= CMF_FILE;
 		break;
+	    case 'e':
+		dat.flags |= CMF_ISPAR;
+		break;
 	    case 'F':
 		sp = &(dat.ign);
 		e = "string expected after -%c";
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index ae42c7b8e..374d9578a 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -197,6 +197,10 @@ static int noreal;
 
 static char *parpre;
 
+/* Flags for parameter expansions for new style completion. */
+
+static int parflags;
+
 /* This is either zero or equal to the special character the word we are *
  * trying to complete starts with (e.g. Tilde or Equals).                */
 
@@ -812,7 +816,8 @@ check_param(char *s, int set, int test)
 		parq = eparq = 0;
 
 	    /* Save the prefix. */
-	    if (incompfunc) {
+	    if (compfunc) {
+		parflags = (br >= 2 ? CMF_PARBR : 0);
 		sav = *b;
 		*b = '\0';
 		untokenize(parpre = ztrdup(s));
@@ -3801,6 +3806,8 @@ addmatches(Cadata dat, char **argv)
     Patprog cp = NULL;
     LinkList aparl = NULL, oparl = NULL, dparl = NULL;
 
+    if (dat->flags & CMF_ISPAR)
+	dat->flags |= parflags;
     if (compquote && (qc = *compquote)) {
 	if (qc == '`') {
 	    instring = 0;
@@ -4562,7 +4569,8 @@ docompletion(char *s, int lst, int incmd)
 	    cs = origcs;
 	}
 	/* Print the explanation strings if needed. */
-	if (!showinglist && validlist && usemenu != 2 && nmatches != 1) {
+	if (!showinglist && validlist && usemenu != 2 && nmatches != 1 &&
+	    (!oldlist || !listshown)) {
 	    Cmgroup g = amatches;
 	    Cexpl *e;
 	    int up = 0, tr = 1, nn = 0;
@@ -7751,6 +7759,7 @@ do_single(Cmatch m)
 {
     int l, sr = 0, scs;
     int havesuff = 0;
+    int partest = (m->ripre || ((m->flags & CMF_ISPAR) && parpre));
     char *str = m->str, *ppre = m->ppre, *psuf = m->psuf, *prpre = m->prpre;
 
     if (!prpre) prpre = "";
@@ -7799,7 +7808,7 @@ do_single(Cmatch m)
 	/* There is no user-specified suffix, *
 	 * so generate one automagically.     */
 	cs = scs;
-	if (m->ripre && (m->flags & CMF_PARBR)) {
+	if (partest && (m->flags & CMF_PARBR)) {
 	    int pq;
 
 	    /*{{*/
@@ -7815,7 +7824,7 @@ do_single(Cmatch m)
 	    if (m->flags & CMF_PARNEST)
 		havesuff = 1;
 	}
-	if ((m->flags & CMF_FILE) || (m->ripre && isset(AUTOPARAMSLASH))) {
+	if ((m->flags & CMF_FILE) || (partest && isset(AUTOPARAMSLASH))) {
 	    /* If we have a filename or we completed a parameter name      *
 	     * and AUTO_PARAM_SLASH is set, lets see if it is a directory. *
 	     * If it is, we append a slash.                                */
@@ -7827,11 +7836,14 @@ do_single(Cmatch m)
 		t = 1;
 	    else {
 		/* Build the path name. */
-		if (m->ripre && !*psuf && !(m->flags & CMF_PARNEST)) {
+		if (partest && !*psuf && !(m->flags & CMF_PARNEST)) {
 		    int ne = noerrs;
 
-		    p = (char *) zhalloc(strlen(m->ripre) + strlen(str) + 2);
-		    sprintf(p, "%s%s%c", m->ripre, str,
+		    p = (char *) zhalloc(strlen((m->flags & CMF_ISPAR) ?
+						parpre : m->ripre) +
+					 strlen(str) + 2);
+		    sprintf(p, "%s%s%c",
+			    ((m->flags & CMF_ISPAR) ? parpre : m->ripre), str,
 			    ((m->flags & CMF_PARBR) ? Outbrace : '\0'));
 		    noerrs = 1;
 		    parsestr(p);
@@ -7841,7 +7853,8 @@ do_single(Cmatch m)
 		} else {
 		    p = (char *) zhalloc(strlen(prpre) + strlen(str) +
 				 strlen(psuf) + 3);
-		    sprintf(p, "%s%s%s", (prpre && *prpre) ? prpre : "./", str, psuf);
+		    sprintf(p, "%s%s%s", ((prpre && *prpre) ?
+					  prpre : "./"), str, psuf);
 		}
 		/* And do the stat. */
 		t = (!(sr = ztat(p, &buf, 0)) && S_ISDIR(buf.st_mode));
@@ -7900,7 +7913,7 @@ do_single(Cmatch m)
 		makesuffix(1);
 	}
     }
-    if (minfo.we && m->ripre && isset(AUTOPARAMKEYS))
+    if (minfo.we && partest && isset(AUTOPARAMKEYS))
 	makeparamsuffix(((m->flags & CMF_PARBR) ? 1 : 0), minfo.insc - parq);
 
     if ((menucmp && !minfo.we) || !movetoend) {