zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh <zsh-workers@sunsite.dk>
Subject: Re: Tags in function files
Date: Wed, 17 Sep 2003 16:30:41 +0000	[thread overview]
Message-ID: <1030917163041.ZM5852@candle.brasslantern.com> (raw)
In-Reply-To: <20030917083752.GC4415@DervishD>

On Sep 17, 10:37am, DervishD wrote:
}
}     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").

The new completion system (there's been a half-hearted attempt to start
using "compsys" to refer to this, to distinguish from "compctl" without
having to write a whole paragraph like this one ... I'm tempted to write
and document a function named "compsys", or at least put an index entry
with that name into the docs) is an extensive example of what can be
accomplished with "zle -C" plus the "compadd" builtin.

The really short summary is that "zle -C" tells zsh how to display the
results computed by your widget, and "compadd" from within the widget
tells zsh what those results are.  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.

} $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.  If, for example, you setopt KSH_ARRAYS, then
the behavior of things like $words won't match the compsys documentation.

A handy debugging tool for widgets of any sort is "zle -M".  E.g.:

zagzig% bung() { 
function> zle -M "words: $words"
function> compadd $words[1]
function> }
zagzig% zle -C bung-word .complete-word bung
zagzig% bindkey ^XB bung-word
zagzig% foo 

If I hit C-x B at this point I see:

zagzig% foo foo
words: foo

If I then type a "g" and hit C-x B again I get a beep (because "g" can't be
matched to the compadd'd match "foo") and see:

zagzig% foo foo g
words: foo foo g


  reply	other threads:[~2003-09-17 16:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-16 20:35 DervishD
2003-09-17  7:48 ` Oliver Kiddle
2003-09-17  8:37   ` DervishD
2003-09-17 16:30     ` Bart Schaefer [this message]
2003-09-17 19:37       ` DervishD
2003-09-18  3:44         ` 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=1030917163041.ZM5852@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.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).