zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Fun with zsh (Re: Associative array ordering (Re: Example function))
Date: Wed, 3 Feb 1999 16:00:52 +0100 (MET)	[thread overview]
Message-ID: <199902031500.QAA12969@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 2 Feb 1999 08:54:15 -0800


Bart Schaefer wrote:

> Following application of your patch, using 3.1.5-pws-6 zsh -f,
> 
>     zsh% foo=('(I*)<TAB>
> 
> only feeps, but
> 
>     zsh% foo(
>     array> '(I*)<TAB>
> 
> autolists the entire contents of the current directory.
> 
> This is the same as the 3.0.5 behavior, but it still seems odd to me.

Whew. The first behavior is the correct one, since the completion code 
should take the `(I*)' as the prefix of the string to complete and as
long as you don't have a file with a name starting with this, nothing
should be matched.

Making this work in every position in arrays wasn't that easy since
the lexer sometimes reported that it was in command position and there 
it started to parse the string itself instead of reporting it as one
string token. In fact, to avoid fiddling with the lexer, I had to add
an in-array-value-flag in get_comp_string (to recognise the end if you 
are completing something like `foo=( ... ); frob <TAB>').

People using the new style completion stuff (and the new-completion-examples
find) who test the thing quoted above will notice that it completes
files beginning with `I' in this case. This is due to the parameter
handling in pfiles(). More precisely, this is due to the fact that we
still haven't got a way to quote strings resulting from a parameter
expansion (supporting the `q' modifier for parameter expansion has
long been on the wish list but still isn't implemented).

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Wed Feb  3 12:07:22 1999
+++ Src/Zle/zle_tricky.c	Wed Feb  3 15:46:24 1999
@@ -919,7 +919,7 @@
 static char *
 get_comp_string(void)
 {
-    int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins;
+    int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins, inarr, ia, parct;
     char *s = NULL, *linptr, *tmp, *p, *tt = NULL;
 
     zsfree(brbeg);
@@ -982,7 +982,7 @@
 	inpush(dupstrspace((char *) linptr), 0, NULL);
 	strinbeg();
 	stophist = 2;
-	i = tt0 = cp = rd = ins = oins = 0;
+	i = tt0 = cp = rd = ins = oins = inarr = parct = ia = 0;
 
 	/* This loop is possibly the wrong way to do this.  It goes through *
 	 * the previously massaged command line using the lexer.  It stores *
@@ -1001,7 +1001,21 @@
 	    linredir = (inredir && !ins);
 	    oins = ins;
 	    /* Get the next token. */
+	    if (inarr)
+		incmdpos = 0;
 	    ctxtlex();
+	    if (tok == ENVARRAY) {
+		inarr = 1;
+		zsfree(varname);
+		varname = ztrdup(tokstr);
+	    } else if (tok == INPAR)
+		parct++;
+	    else if (tok == OUTPAR) {
+		if (parct)
+		    parct--;
+		else
+		    inarr = 0;
+	    }
 	    if (inredir)
 		rdstr = tokstrings[tok];
 	    if (tok == DINPAR)
@@ -1043,6 +1057,7 @@
 		clwpos = i;
 		cp = lincmd;
 		rd = linredir;
+		ia = inarr;
 		if (inwhat == IN_NOTHING && incond)
 		    inwhat = IN_COND;
 	    } else if (linredir)
@@ -1084,8 +1099,13 @@
 	zsfree(clwords[clwnum]);
 	clwords[clwnum] = NULL;
 	t0 = tt0;
-	lincmd = cp;
-	linredir = rd;
+	if (ia) {
+	    lincmd = linredir = 0;
+	    inwhat = IN_ENV;
+	} else {
+	    lincmd = cp;
+	    linredir = rd;
+	}
 	strinend();
 	inpop();
 	errflag = zleparse = 0;
@@ -3313,7 +3333,12 @@
 	    case IN_ENV:
 		compcontext = "value";
 		compcommand = varname;
-		usea = 0;
+		if (!clwpos) {
+		    clwpos = 1;
+		    zsfree(clwords[1]);
+		    clwords[1] = ztrdup(s);
+		}
+		aadd = 1;
 		break;
 	    case IN_COND:
 		compcontext = "condition";

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1999-02-03 15:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-03 15:00 Sven Wischnowsky [this message]
1999-02-03 17:38 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
1999-02-05  8:58 Sven Wischnowsky
1999-02-05  7:45 Sven Wischnowsky
1999-02-04  8:06 Sven Wischnowsky
1999-02-04 16:11 ` Bart Schaefer
1999-02-03 10:41 Sven Wischnowsky
1999-02-02 17:19 Sven Wischnowsky
1999-02-02 17:48 ` Bart Schaefer
1999-02-02 12:26 Sven Wischnowsky
1999-02-02 16:54 ` Bart Schaefer
     [not found] <jarausch-990202124256.A09694@numa1>
1999-02-02 11:59 ` Bart Schaefer
1999-02-02 12:10   ` Bart Schaefer
1999-02-02  8:01 Associative array ordering and selective unset (Re: Example function) Sven Wischnowsky
1999-02-02 11:31 ` Fun with zsh (Re: Associative array ordering (Re: Example function)) Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199902031500.QAA12969@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).