zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: selective parameter completion
Date: Fri, 11 Aug 2000 14:16:18 +0200 (MET DST)	[thread overview]
Message-ID: <200008111216.OAA11643@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Fri, 11 Aug 2000 09:44:21 +0200 (MET DST)


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:
> > : $(( <tab>
> > 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


             reply	other threads:[~2000-08-11 12:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-11 12:16 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-08-11  7:44 Sven Wischnowsky
2000-08-10 20:06 Oliver Kiddle

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=200008111216.OAA11643@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).