Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Tags in function files



    Hi Bart :))

    Thanks a lot for your exhaustive answer, I've learned a lot :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> }     OK, thanks :) BTW, the special parameters as 'words' and the
> } like, are too created and initialized by compinit (I mean, the new
> } completion system...)?
> No, those are set up by the ZLE internals.  However, they're provided
> only to "completion widgets", which means those created with "zle -C"
> (as opposed to those created with "zle -N").

    OK, now all makes sense. I was testing with a dummy widget (NOT a
completion one...) and I was able to use 'zle complete-word' inside
my widget, but I couldn't use '$words' (it expanded to nothing). On
the other hand, I created a dummy completion widget with zle -C but
then I wasn't able to use the predefined widgets inside. Namely
something like this:

my_comp () {
    zle .complete-word
}

zle -C dummycomp complete-word my_comp

bindkey "^O" dummycomp

    When I hit '^O' zsh complains:

my_comp:zle:1: widgets can only be called when ZLE is active

    Is this intended or am I totally clueless? I mean, instead of
using compadd, I would like to be able to last-resort to some
predefined completion widget, or even call some zle widget to move
the cursor, retrieve the story, clean the command line, etc... That
is, using some of the zle facilities inside my completion widget.

> The new completion system

    I really like your suggestion, let's call it compsys ;)))

> is an extensive example of what can be
> accomplished with "zle -C" plus the "compadd" builtin.

    I've been reading some of the functions: compinit, compadd, some
of the _* functions, etc... It's a very good job, truly. I'm amazed...
 
> Then for finer control you can get into playing with the values of
> the "compstate" parameter.  You probably got all that already from
> PWS's user guide, intro to chapter 6.

    I've read the entire guide, since it seems to be pretty valid
(only minor differences with my version of zsh). In fact I've learned
a lot of zsh, not only completions, but globbing, parameter
expansion, zle, etc... The guide is great. Now I feel like I can go
for the Zsh manual ;))) In the interim I'm reading the FAQ.

> } $words doesn't seem to work, so I'm thinking about using 'BUFFER' for
> } command line parsing in order to call one of the completion functions
> } I need. Like _main_complete, but lots simpler.
> Keep in mind that one of the things _main_complete does is reset a whole
> lot of setopts to be sure that all completion functions operate in the
> same syntactic environment.

    Oh, yes, I know, but I just want to learn and make some
completions work in my box. I will try my best to set the options so
if I made a change it doesn't affect the completions.

> If, for example, you setopt KSH_ARRAYS, then
> the behavior of things like $words won't match the compsys documentation.

    My problem with the compsys documentation is that I don't know
which parameters, tags and the like are defined by compsys and which
ones are controled by Zsh guts ;)) I'm learning, slowly but surely ;)
 
> A handy debugging tool for widgets of any sort is "zle -M".  E.g.:

    THANKS!!!! That's nice!

    Thanks again for your kind answer. This is a difficult issue for
me and I really don't have all the time I would like to put it on
learning Zsh, and your help is very valuable.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/



Messages sorted by: Reverse Date, Date, Thread, Author