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

Re: [PATCH] Add API wrapper to ${+_comps[...]}



Bart Schaefer wrote on Mon, Oct 05, 2015 at 15:11:48 -0700:
> On Oct 5,  9:51pm, Daniel Shahaf wrote:
> } Subject: Re: [PATCH] Add API wrapper to ${+_comps[...]}
> }
> } Bart Schaefer wrote on Sat, Oct 03, 2015 at 17:49:19 -0700:
> } > 
> } > (Why two separate patches both to compsys.yo?)
> } 
> } One logical change per commit.
> 
> But you don't care about one logical commit per zsh-workers sequence
> number?  I mean, I'm not unreasonably sticky about it, but I try to
> keep it that way.
> 

How would I handle a case such as 36725 (three patches to a single
module)?

I know some people handle this with git-send-email, but I don't have
that set up.

Would it help to write the commit messages and changelog entries as
36725/0001, 36725/0002, etc, where the running counter is the first part
of the filename?  (which is generated by 'git format-patch')

> } > On the other hand there are tests for whether a particular function
> } > is defined.  If that function is destined to be assigned to _comps[x]
> } > perhaps it would be better to check for _comps[x] already defined
> } > instead.
> } 
> } _comps[x] being already defined in what sense?  I can think of three
> } meanings: (a) hash key exists
> 
> That sense.
> 
> The point being that if we're going to bother defining "compexists"
> then maybe we ought to use it instead of (( ${+functions[_name]} )).
> It couldn't replace all such tests, since in most cases those are
> "helper" functions rather than values in $_comps, but perhaps some.
> 

It seems most cases are of the "allow an helper function to be
overridden" variety.  The usage in _calendar:3 is an exception, but
couldn't benefit from compexists.

> I'm trying to find a metric for usefulness.

The difference between

   f() {
     [[ $# == 1 ]] || return 2
     (( $+_comps[$1] ))
   }
and
   g() {
     [[ $# == 1 ]] || return 2
     (( $+_comps[$1] )) && (( $+functions[$_comps[$1]] ))
   }

is how they handle the case 'compdef _foo foo' with _foo() not having
being defined yet (nor marked for autoload).  Is this a common case?
When does it happen?



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