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

Re: using the description from _arguments foo:description:->state



On Sep 21,  7:10pm, Oliver Kiddle wrote:
}
} So given that you "don't think adding -d buys much" and there is the
} compatibility issue I mentioned, what would you suggest?  A local in
} _main_complete would fall down in the case of a function using states
} calling another function that also uses states but which doesn't declare
} state_descr local.

That'd be a bug in one or the other of those functions, would it not?
Declaring state_descr in _main_complete is just to keep it from leaking
out to the top level, not to make it possible for functions that need
it to avoid declaring it.  There's a huge list of other variables that
already "fall down" in this way; one more isn't going to kill us.  (I
don't *like* the necessity of that huge list, but there it is.)

} Perhaps _arguments/_values could leave state_descr alone where
} the description is blank or consists of just a space.

Unfortunately both _arguments and _values need to erase the existing
value of the state-related variables before they know whether there
are any states or descriptions to assign.  The right way to do this
probably would have been to pass the names of the variables to set
rather than rely entirely on scoping, but [unless someone wants to
undertake a major drudgework project to update the whole Completion
tree] it's too late to deal with that now.

E.g., _arguments has (after my not - committed patch):

  context=()
  state=()
  state_descr=()

These could all become

  (( $+context )) && context=()
  (( $+state )) && state=()
  (( $+state_descr )) && state_descr=()

and similarly for the place that useful values are assigned to each of
them (there's only one such place), but that still doesn't help for a
recursive call to _arguments or for a call to _values from _arguments.



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