From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: -subscript- completion for assoc array
Date: Mon, 15 Mar 1999 17:00:14 +0100 (MET) [thread overview]
Message-ID: <199903151600.RAA23501@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Mon, 15 Mar 1999 16:10:32 +0100
Peter Stephenson wrote:
> Is there some math mode behaviour still built into subscript completion? I
> can't complete the -*- elements of _comps, although they are listed all
> right immediately after the [ and are entered OK with menu completion.
>
> % $_comps[-def<TAB>
>
> tries to complete variable names. Significantly, it claims it's allowing
> two errors and the set I get is
>
> fignore hep_env_sh perl5lib testhash vers
> foo keys ret texinputs
> fpath lf sets ufmt
>
> so I suspect the - has been chucked out at some point. (Since you're
> wondering :-), the list consists of variables starting in f (delete two
> characters) or with e second (replace two characters) or with f second
> (delete one and transpose the other two).)
The patch below only makes the parameter name correctly handled.
The problem with the missing `-' is not handled, but I found the
reason for it (and am not sure how we should change it). The reason is
that inside subscripts, match-mode parsing is done to get the string
to complete, which normally is a string of characters on which
`iident(c)' yields true. This is what one wants in math envs including
normal subscripts. Hm, I have to leave now so I won't be able to send
a patch for this now (hance this mail). I'll think some more about
this, but if some of you have ideas, let me know.
Possibilities include: give the whole subscript string to the function
(which is a bit ugly for normal subscripts), and let the C-code find
out what kind of parameter we have -- and let it report a new context
for assocs.
> I don't think it matters much, but I'm now using the slightly modified
> _subscript below. (It does show I shouldn't get the variable names at all
> in this case and hence compstate[parameter] isn't set properly, either.)
I think this is reasonable (and it seems I didn't think when writing
that...), so the patch below also changes `_subscript'
Bye
Sven
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c Mon Mar 15 10:52:39 1999
+++ Src/Zle/zle_tricky.c Mon Mar 15 16:43:38 1999
@@ -1322,18 +1322,17 @@
* as being in math. */
if (inwhat != IN_MATH) {
int i = 0;
- char *nb = (iident(*s) ? s : s + 1), *ne = NULL;
+ char *nnb = (iident(*s) ? s : s + 1), *nb = NULL, *ne = NULL;
for (tt = s; ++tt < s + cs - wb;)
if (*tt == Inbrack) {
i++;
+ nb = nnb;
ne = tt;
} else if (i && *tt == Outbrack)
i--;
- else if (!iident(*tt)) {
- nb = tt + 1;
- ne = NULL;
- }
+ else if (!iident(*tt))
+ nnb = tt + 1;
if (i) {
inwhat = IN_MATH;
insubscr = 1;
diff -u oc/Base/_subscript Completion/Base/_subscript
--- oc/Base/_subscript Mon Mar 15 10:08:48 1999
+++ Completion/Base/_subscript Mon Mar 15 16:51:33 1999
@@ -1,10 +1,7 @@
#defcomp -subscript-
-local ret=1
-
-_compalso -math- && ret=0
-
-[[ ${(Pt)${compstate[parameter]}} = assoc* ]] &&
- compgen -k "( ${(kP)${compstate[parameter]}} )" && ret=0
-
-return ret
+if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
+ compgen -S ']' -k "( ${(kP)${compstate[parameter]}} )"
+else
+ _compalso -math-
+fi
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-03-15 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-15 16:00 Sven Wischnowsky [this message]
1999-03-15 16:18 ` Peter Stephenson
-- strict thread matches above, loose matches on Subject: below --
1999-03-16 10:49 Sven Wischnowsky
1999-03-15 15:10 Peter Stephenson
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=199903151600.RAA23501@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).