zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@math.gatech.edu
Subject: Re: new completion behaviour version 2
Date: Mon, 9 Nov 1998 10:04:03 +0100 (MET)	[thread overview]
Message-ID: <199811090904.KAA07856@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Fri, 6 Nov 1998 11:02:24 -0800


Bart Schaefer wrote:

> ...
> 
> 
> If we're going to add associative arrays anyway (which I take it would
> just be some kind of parameter syntax for frobbing a hash table) then
> I'd just as soon have the set of scalars (CMDSTR, CURWORD, etc.) be in
> such an associative array.

Interesting idea, I'll have to think about this a bit more...

> 
> As for the words of the current command ... I'm thinking I'd like them
> to come in as the positional parameters.  We already have syntax for
> altering the $* array (shift, set, and 3=foo among other things); it
> should be possible to recapture the contents after the function exits;
> and it is an extremely intuitive way to refer to the command line.
> 
> (You can almost do this today by using
> 	read -Ac argv ; shift
> in a compctl -K function, except that stomps the $1/$2 prefix/suffix.)

Yes, sounds good.

> 
> } For producing the actual matches there is another builtin, say
> } `compadd'.  [...]
> } with a different way to handle control flags (-U, -q,
> } grouping,...). We could make these flags be used `from now on' and
> } probably have a way to save/restore the current set of control flags
> } (whose state would be stored together with the matches produced),
> } e.g. (in an easy-to-read syntax):
> } 
> }   compadd -push
> }   compadd -quote -suffix '/'
> }   compadd -files               # optional glob pattern here
> }   ...
> }   compadd -pop
> 
> The main problem I have with this is that it's too easy to forget the
> "pop".  If you want to do something of this sort, it really needs its
> own syntax.  One way to accomplish that without having to muck about
> with the zsh parser is to supply ONLY the "push" version of the command,
> but define it to extend exactly to the end of the current function, as
> for "local" variables and "setopt localoptions".  The user can control
> scope by defining functions that call one another.
>  

I wasn't too happy about this, just because this `pop'. On the other
side I think that the function scope may be too big for this. But
maybe we can just do what you suggest and if we find out that we would 
like to have a possibility to `pop' to a previous state we can add it
later.

> } I.e. use the normal shell tests and the special variables. But there
> } is a problem with this: with compctl the `-x' - tests not only test
> } for a certain condition, but also report some information back,
> } namely: the length of an prefix that should be ignored in the
> } completion string and (with `r[a,b]') a restriction on the command
> } words that should be used with `compctl -L'.
> 
> Pardon my density, but I don't follow the connection between r[a,b] and
> `compctl -L'.  Do you mean `compctl -l'?

Yep, of course, this was a typo.

> 
> }   complist -k
> }   complist -c
> 
> Incidentally, with respect to menu completion, I don't think the widget
> should get involved directly in cycling through the menu choices.  (I
> can easily be convinced otherwise, but right now I don't see a compelling
> argument.)  Once the the control flags have indicated that you have a
> menu of choices, don't invoke the widget again until the prefix changes.
> That is, the widget can say "here are the completions, and here is where
> you insert them" but then let hardwired code take over cycling through
> the menu if there are multiple matches.

Interesting point of view. I thought we wanted to give the user the
possibility to build widgets that have full control over the
completion mechanism, i.e. the possibility to re-implement all the
things the completion code offers now.
But again, yes, we probably should start with a minimal solution and
improve that later if we need/want to have it.

> ...
> 
> Recexact can be emulated entirely by the wiget by simply producing only
> a single match.  Listambiguous can be a flag attached to the generated
> list of matches, can it not?
> 

Yes. The question is: should the completion code do this automatically 
or should the user request it explicitly.

> ...
> 
> What I had in mind a while back was an interface to add one or more
> matches with options for the controls associated with that collection
> of matches; plus interfaces (possibly commands, possibly variables) to
> obtain the information that's currently only available to compctl and
> pass it to the add-matches interface.
> 
> So for example there would be a command or an array variable that gives
> the names of all the disabled commands, and you'd do
> 
> 	compadd $disabled
> 
> instead of
> 
> 	compadd -dFB
> 
> (That's probably not the best example, but just to give the idea.)
> 

I like this. But I wouldn't like to have to do

    compadd $(compinfo -disabled)

The $(...) is what I don't like. Using variables would be much more
effective, but these would be special variables and there seems to be
reluctance against more special variables (not from me, I always liked 
them).

> ...
>
> I agree, and I liked your comptest idea.  For example, something like
> 
> 	if comptest index -1 / ; then
> 
> to mean what n[-1,/] accomplishes now.  (There could even be a flag in
> [[ ]] to mean "test completions", e.g., [[ -C index -1 / ]] for the
> above.)

I didn't think about changing [[...]], interesting. (Although that
would require changes in completely differnt parts of the code, of
course.)

> ...
> 
> Recursively invoking completion functions is a good idea, and IMNSHO is
> the best argument that I can think of for passing the command words as
> the positional parameters.  (There is of course still the issue of $0,
> but that's not too terrible.  Just assign to CMDSTR or whatever takes
> its place in the associative array, before calling the other function.)

Of course. My suggestion was to have a top-level function that calls
other functions which might call other functions...


> 
> On Nov 3,  4:58pm, Sven Wischnowsky wrote:
> } Subject: new completion behaviour version 2
> }
> } The coding scheme for xor'ed completion is trivial. The code for `-x'
> } stuff will be done using `if'-tests with the information stored in
> } local variables. We then need a way to notify the completion code
> } about two things it will have to use (to be able to do the same things 
> } `-x' can): the length of an ignored prefix of the current word and
> } (for `-L') which part of the words-array should be taken as command
> } words.
> 
> I still think you must mean `-l' there.  Un-confuse me, please.

Yes, this was `copying a typo without further thinking'.


Bye
 Sven


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


             reply	other threads:[~1998-11-09  9:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-09  9:04 Sven Wischnowsky [this message]
1998-11-09 23:09 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
1998-11-02 10:36 completion behaviour (was: zsh-workers: zsh-3.1.5 released) Sven Wischnowsky
1998-11-02 11:29 ` Zefram
1998-11-02 12:00   ` Sven Wischnowsky
1998-11-02 12:31     ` Zefram
1998-11-02 13:48       ` Sven Wischnowsky
1998-11-03 15:58         ` new completion behaviour version 2 Sven Wischnowsky
1998-11-03 17:15           ` Bart Schaefer
1998-11-06 19:02           ` 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=199811090904.KAA07856@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@math.gatech.edu \
    /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).