Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How completions work, do they require fpath?
- X-seq: zsh-users 21193
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: How completions work, do they require fpath?
- Date: Thu, 28 Jan 2016 08:37:12 +0100
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ltbDl1d/+Oznq6aolyhiXZzC5L2GBogYOK/35kRIGNI=; b=Pikd//JpmbSLcIxiDbK7C8RNXjXb6Q1O0z0tuT5/AHfdRPyV5BaLI9b+YjfJeXXrs0 w8ELAfvehp5W8ekGd88vsl38l72BU9S5ZdUXFXulgjPuUhiRf44XlNwqVwEb1qQLkpzz mu1kcB4dyDOZnMOhb47PLQvwXTeh57c35MYBLPKT8wXWh+vDyn5Xh46qwXp3ZlyasIwY uemBxir9C8IgupIlQyjjOBBmBFL4VnOcq/pGe5TZplJwRKS78H/lyaeDYUoDr6tqiSZl bELuNxmGrJJd8gQHcmgJa1e2C/JRXVFqYxs6l+w6rVJFwtu331I3rEN4rxxlOcb+Lw+M YNEQ==
- In-reply-to: <160127231104.ZM17647@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCqw_Z+RnjzwEtoRVLSE1A9JSyVQYpg1E=6u5em5qDdkg@mail.gmail.com> <160126232017.ZM3789@torch.brasslantern.com> <CAKc7PVBcpYc4JjzWfuiqb=wjeQxtGF=vMDgxT7QTdLR2mPcJag@mail.gmail.com> <CAKc7PVCMPay34XS9up_CP-iZ79xPt2sZw35ngPBZZGN=_SRX_Q@mail.gmail.com> <160127231104.ZM17647@torch.brasslantern.com>
On 28 January 2016 at 08:11, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jan 26, 6:18pm, Sebastian Gniazdowski wrote:
> }
> } my current understanding of the completions is that if a file-function
> } with name starting with "_", and having "#compdef ..." in first line
> } of content, is found in $fpath, then, if compinit is run, the function
> } will be autoloaded and used by _main_complete. Am I missing something
> } here?
>
> No.
One thing emerged – I was expecting that empty say "_cp" will just be
ignored, because of lack of #compdef, however it isn't – it blocks
other "_cp" files from loading.
> } Does this mean that compinit should be best run once after all needed
> } fpath updates?
>
> Ideally yes, but really #compdef is just a way to have the compdef
> function invoked automatically for some files. If the plugin is
> already calling autoload + compdef directly, compinit isn't needed.
Interesting, have to test this
> Other than that, the shadow-autoload trick already used in zplugin
> should work for completion autoloads, although they would not get
> recorded in ~/.zcompdump (and you wouldn't want them to be, in that
> circumstance).
That worries me, I hope my shadowing doesn't interfere with completion
autoloads. That said, it seems that plugin would have to invoke
"compinit" to trigger such autoloads?
> } I wanted to have fpath "clean", and I guess I can still have it
>
> I've been a little puzzled all along about why you object to having
> entries in fpath.
I wasn't 100% sure myself if my expectations of fpath being "clean"
are reasonable. However now after implementing completion support to
Zplugin I see it was a good thing. Really, really nice thing to just
have "~/.zplugin/completions" instead of 10 entries:
https://asciinema.org/a/dmacq18klhw9rfxfffrhweh6a
> } like this: create ~/.zplugin/completions, add it to fpath, simlink
> } any plugin's "_*" files there.
>
> There's another possibility: use zcompile. Gather up the names of
> all the autoloadable files defined by the plugins, and then run for
> example
>
> zcompile ZPLUGINS $all_the_paths_of_autoloadable_files
>
> This will create a (large) file ZPLUGINS.zwc containing all potential
> autoloads. Then just add that file name (not a directory name in
> this special case) to fpath:
>
> fpath+=($PWD/ZPLUGINS.zwc)
>
> and you're done. Some checks that you don't clobber the file when
> a new shell starts up are advised, because zsh typically mmap's it and
> shares it.
Will think about that, currently I've implemented completion handling
via simlinks, and this gives a nice feature – I can check from which
plugin a completion comes from (as seen in the asciinema video)
Best regards,
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author