zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: Re: -subscript- completion for assoc array
Date: Mon, 15 Mar 1999 17:18:38 +0100	[thread overview]
Message-ID: <9903151618.AA36652@ibmth.df.unipi.it> (raw)
In-Reply-To: "Sven Wischnowsky"'s message of "Mon, 15 Mar 1999 17:00:14 NFT." <199903151600.RAA23501@beta.informatik.hu-berlin.de>

Sven Wischnowsky wrote:
> 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 wouldn't have thought it would be too hard just to pass the whole string
to the -subscript- handler, and inside that, if the parameter is not an
assoc, simply IPREFIXify anything which is not alphanumeric before handing
the rest on to the -math- handler.  You don't even need special handling
for variables with funny names, since they're always a single character so
can't be completed further.  Unless I've missed something.

You could even argue that the -math- handler could be made responsible for
deciding what to complete and what to IPREFIXify in every case.  After
thinking about it, I like this better, since it keeps string handling
consistent within math-like contexts.  It also allows you to have
completion for the whole expression.  For example, you could arrange for

(( <TAB>                  # -> selection of parameters as usual
(( foo <TAB>              # -> matches "[a-z]  *", cycle through selection
                          #    of operators
(( foo + <TAB>            # -> it's a +, generate my own special
                          #    list of numbers to add to: 3.14159, 42,
                          #    1000009, ...

I'm not suggesting it's actually worth writing a function which does any of
that apart from the first bit, even I can type `++' without feeling the
need to hit TAB, but simply that it increases flexibility and decreases
special-casing in the C code if this is transferred to the shell function.

(Except, of course, when calling old completion, in which case you've got
to do as much as is reasonable in C.)


By the way, it's a bit annoying that the command is called `compdef' while
the lines at the tops of the functions to do the same thing automatically
are still `defcomp' etc.  If it's not yet too late, it might be a good idea
to change these to `compdef', `compdefpat' and `compdefkey'.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-03-15 16:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-15 16:00 Sven Wischnowsky
1999-03-15 16:18 ` Peter Stephenson [this message]
  -- 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=9903151618.AA36652@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --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).