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

Re: [PATCH] _compdef: Use zsh/param instead of a glob.



Matthew Martin wrote on Sun, 26 Aug 2018 20:09 -0500:
> On Sun, Aug 26, 2018 at 10:54:04AM +0000, Daniel Shahaf wrote:
> > In particular, this allows functions defined inside another file to be
> > offered, such as various __git_foo() helpers defined in ${^fpath}/_git.
> 
> I don't think this is a good idea at present. While the completion
> system does use the _ prefix namespace, I don't see anything in the
> documentation reserving the namespace to the completion system. There
> are already a number of projects[0] that use the _* namespace.

In general, it is better to offer too many completions than too few.
(In other words, better to have false positives than false negatives.)
For example, the other day I needed __git_branches; I didn't
particularly mind to have the entire timestamp-named z-sy-h cast there
since it didn't get in the way, due to namespacing.

That said, if there is some way to generate a set of names that is less
complete but has fewer false positives, we could offer that set under
one tag and the ${(k)functions[(I)_*]} set under another tag, to allow
users to get their preferred way by setting the tag-order style.

> Perhaps in 5.6 document that only completion functions should start
> with an underscore and then apply this patch for 5.7 so that users
> have time to adapt.

I don't know if we should deprecate user functions being named `_*`.  We
could point out in the docs that the completion system uses this
namespace so the world would be a _slightly_ better place if user code
used some other namespace, but I would stop short of making this a hard
requirement.

(Incidentally, I never understood why completion functions didn't use a
proper namespace, zshfoo_* or some such, like virtually everyone else —
but that ship has sailed.)

Cheers,

Daniel
(except gettext)



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