From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15811 invoked from network); 11 Aug 2000 12:17:14 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 11 Aug 2000 12:17:14 -0000 Received: (qmail 11370 invoked by alias); 11 Aug 2000 12:16:32 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12592 Received: (qmail 11363 invoked from network); 11 Aug 2000 12:16:29 -0000 Date: Fri, 11 Aug 2000 14:16:18 +0200 (MET DST) Message-Id: <200008111216.OAA11643@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Sven Wischnowsky's message of Fri, 11 Aug 2000 09:44:21 +0200 (MET DST) Subject: Re: PATCH: selective parameter completion I wrote: > Oliver Kiddle wrote: > > ... > > > How does the implementation of _math differ from if compset -P and > > compset -S were used to move the patterns from PREFIX to IPREFIX and > > SUFFIX to ISUFFIX? It would be nice if spaces were treated more > > cleanly, for example: > > : $(( > > doesn't complete parameters but quotes the space. > > Hm, it does complete parameters for me (and only integers and > floats). But the quoting is... urgh. Another thing is that _math > should not complete the special-character parameters (like !, $, > etc.) and that it should use parameter-expansion completion after a > `$' inside a math expression. The latter has to be fixed in C code, > I'll have a look. And the quoting has to be fixed in C-code, too, I > think, because the space is already reported in quoted form, which it > shouldn't when completing in a math expression. Ok, here's the patch. It avoids quoting the string when completing inside a math expression and it makes it be tokenized so that completion after a `$' is completed like every other parameter- expansion. That hunk in _parameters keeps the special parameters like `!' and `$' from being quoted. And I forgot to answer the first part: of course using compset should do the same. But why use it? Is it really easier to read? And I don't think it's faster or something. And yet another thing I forgot to point out: making the function complete only integers and float parameters in math contexts really only works in a perfect world. But as it is, we often use scalar parameters to store numbers that are then used in math contexts. So we either need to check the value of the parameters (at least if it's a scalar), or we *really* need the parameter-patterns (or -types) style so that people can override the default of completing only integers and floats. Bye Sven Index: Completion/Core/_parameters =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Core/_parameters,v retrieving revision 1.3 diff -u -r1.3 _parameters --- Completion/Core/_parameters 2000/08/10 21:22:25 1.3 +++ Completion/Core/_parameters 2000/08/11 12:08:05 @@ -12,4 +12,4 @@ zparseopts -D -K -E g:=pattern _wanted parameters expl parameter compadd "$@" \ - -k "parameters[(R)${pattern[2]}~*local*]" + -Q -k "parameters[(R)${pattern[2]}~*local*]" Index: Src/Zle/compcore.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v retrieving revision 1.37 diff -u -r1.37 compcore.c --- Src/Zle/compcore.c 2000/07/18 08:37:15 1.37 +++ Src/Zle/compcore.c 2000/08/11 12:08:06 @@ -664,7 +664,7 @@ zsfree(compprefix); zsfree(compsuffix); if (unset(COMPLETEINWORD)) { - tmp = multiquote(s, 0); + tmp = (linwhat == IN_MATH ? dupstring(s) : multiquote(s, 0)); untokenize(tmp); compprefix = ztrdup(tmp); compsuffix = ztrdup(""); @@ -675,11 +675,11 @@ sav = *ss; *ss = '\0'; - tmp = multiquote(s, 0); + tmp = (linwhat == IN_MATH ? dupstring(s) : multiquote(s, 0)); untokenize(tmp); compprefix = ztrdup(tmp); *ss = sav; - ss = multiquote(ss, 0); + ss = (linwhat == IN_MATH ? dupstring(ss) : multiquote(ss, 0)); untokenize(ss); compsuffix = ztrdup(ss); } Index: Src/Zle/zle_tricky.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v retrieving revision 1.18 diff -u -r1.18 zle_tricky.c --- Src/Zle/zle_tricky.c 2000/06/29 06:59:00 1.18 +++ Src/Zle/zle_tricky.c 2000/08/11 12:08:06 @@ -1311,6 +1311,7 @@ } else insubscr = 1; } + parse_subst_string(s); } /* This variable will hold the current word in quoted form. */ qword = ztrdup(s); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de