From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: How completions work, do they require fpath?
Date: Thu, 28 Jan 2016 08:37:12 +0100 [thread overview]
Message-ID: <CAKc7PVCaf3qbwq_5RS-EwqHnhC+fSMPn+c4bJMuib9qYnyhcGA@mail.gmail.com> (raw)
In-Reply-To: <160127231104.ZM17647@torch.brasslantern.com>
On 28 January 2016 at 08:11, Bart Schaefer <schaefer@brasslantern.com> 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
next prev parent reply other threads:[~2016-01-28 7:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 17:18 Sebastian Gniazdowski
2016-01-26 19:51 ` Sebastian Gniazdowski
2016-01-27 7:20 ` Bart Schaefer
2016-01-27 7:59 ` Sebastian Gniazdowski
2016-01-28 7:11 ` Bart Schaefer
2016-01-28 7:37 ` Sebastian Gniazdowski [this message]
2016-01-28 7:39 ` Sebastian Gniazdowski
2016-01-28 23:23 ` Bart Schaefer
2016-01-29 8:02 ` Sebastian Gniazdowski
2016-01-31 19:26 ` Bart Schaefer
2016-01-28 19:29 ` 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=CAKc7PVCaf3qbwq_5RS-EwqHnhC+fSMPn+c4bJMuib9qYnyhcGA@mail.gmail.com \
--to=sgniazdowski@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/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).