Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: WIP _units
- X-seq: zsh-users 30732
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: "Mark J. Reed" <markjreed@xxxxxxxxx>
- Cc: Oliver Kiddle <opk@xxxxxxx>, christopher@xxxxxxxxx, zsh-users@xxxxxxx
- Subject: Re: WIP _units
- Date: Fri, 31 Jul 2026 11:39:18 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iDyl7GeBd2R06kdiN3ANzEu6kwrsgSpIbrIGWr8PxC0=; fh=XKfuL0nOvPOl/hNr4FPU5HVv75biZDrz4lHgZYCK7NU=; b=dUwDYXg8JU6eMOPJSSD2iHU5IkSj13osh1GNlm17cpKWNAPtktXreKWBhtL8zXoQ5+ DkFmIvQ86RK0iVh8+X9WxprtQu2xjdOML1otsCHRbI2TsecAtdNF8klImGHDa5okxq65 hcrE4lO5WKBSjKti/QmeKgSyZtStYB/DJW6qgHERFcoQpeHQvyRp7lo1gcvdLCu8EXE1 vlYq0JM2L/QH2gWay+omtwuYMW3gu1qNOcTEPAu/UCSEbajfkXtE73835Ps8si5hs7IF Y7me12qFoUyvWpFBwaNuc+SwoVHYxnbfepi+eeUGQgm6RhnjFb6gdmKQG/HesmCC/rKV s2OQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1785490774; cv=none; d=google.com; s=arc-20260327; b=Bw92+QRWmJXPWzk49G/sbvQyZIshVXGW6gJ/0M/8AQ6+Ax/vYzXNI24/AH+Gm3ZW94 +t9JYZ+LAK+SEGyxt6ZICxmjKLNCs3F9WpvwJK29VCWXz9OPulbqQoWvdMvzW9jBhvpt fXz/26/C51wrvYdDGgwoXq30VMMTxsZd40B2fBZSQd5dV+nwYdfe51tEOF5JQWVdDzm7 aTB0RPVlbEqWaLFyjLi2H4Y1fgTokVsQQBgi3j4ayz+3S8pp7/UHr5B8Pb5K2VCa+SG1 3ISUO+5p3aPByLHIhdhzFZFhhjW7tvT+Y18d4HTN3VuXkeZMlQ89Y+c9Lbqfe97a3w8q oFKg==
- Archived-at: <https://zsh.org/users/30732>
- In-reply-to: <CAA=-s3yUzzMDNiRMO_oL41zuxyF91LbgmpuHZigf+vo65H_wdA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <20260728222856.2eb5ada6@obelix.mag.magnix.de> <98123-1785408670.414079@cZAh.Zwua.Wuhh> <CAA=-s3yUzzMDNiRMO_oL41zuxyF91LbgmpuHZigf+vo65H_wdA@mail.gmail.com>
On Thu, Jul 30, 2026 at 6:06 PM Mark J. Reed <markjreed@xxxxxxxxx> wrote:
> On Thu, Jul 30, 2026 at 7:07 AM Oliver Kiddle <opk@xxxxxxx> wrote:
>>
>> 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
>
> Yeah, I wouldn't use [A-z]. Also adding _ to it to get [A-z_] is redundant, because the _ is already included in the A-z range, along with [, \, ], ^, and `.
>
> For most applications [[:alnum::]] is best. Of course, it's also locale-dependent; in the C locale it's equivalent to [A-Za-z0-9], but in other locales it can include characters outside the ASCII range. Last I checked, units(1) was ASCII-only (e.g. it uses u- instead of μ- for micro-).
(Please don't top post, it's a pain to fix.)
You might want to check again,
You have: µm
You want:
Definition: micro m = 1e-06 m
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author