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

Re: WIP _units



christopher@xxxxxxxxx wrote:
> i'm trying to update _units to allow completion for e.g. `units area_<TAB>`
> which currently breaks with the underscore. I couldn't make out what i have
> to add to compadd to make this work.
> Any suggestions?

The problem is with the two compset commands early in the function which
try to strip off characters not belonging to the units like numbers. They
are removing `area_` from the completion matching because of the
underscore. Try adding the _ into those patterns too:

  compset -P '*[^[:alnum:]_]'
  compset -S '[^[:alnum:]_]*'

>  testfiles=(
> -  /usr/share/units.dat		# GNU on Fedora

Did you make any actual changes here or is this purely realignment?

On my system, more than one file matches including an extra currency
one. The completion ignores that second file. I can't see why it needs a
loop instead of something like $^testfiles(N) adding also Y1 to the
qualifier if only one should be matched.

> -units=(${${all:#^[[:alnum:]]##([\(\]]*|)}%%\(*})
> +units=(${${all:#^[0-9A-z_]##([\(\]]*|)}%%\(*})

I'd keep the character class rather than use something like A-z which
may include 6 extra ASCII characters, so e.g:

  units=( ${${all:#^[[:alnum:]_]##([\(\]]*|)}%%\(*} )

Oliver




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