Author :
Pierre Le Marre
Date :
2025-03-26 10:35:22
Hash :6fc6e64b Message :rules: Added extended wild cards <none>, <some> and <any>
Added the following wild cards to the rules file syntax, in addition
to the current `*` legacy wild card:
- `<none>`: Match *empty* value.
- `<some>`: Match *non-empty* value.
- `<any>`: Match *any* (optionally empty) value. Its behavior does not
depend on the context, contrary to the legacy wild card `*`.
This will enable writing much simpler rules, see [!764] for an example
of tricky rules in the `xkeyboard-config` project, that would benefit
from the new wild cards.
[!764]: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/merge_requests/764
The verbose wild cards are preferred to single characters:
- More intuitive: self-explanatory.
- Does not steal syntax from other token.
- Extensible syntax, should we need it.
A previous proposal used the characters (`!`, `+`, `?`) for their
similarity with the corresponding syntax of regular expressions
(negative assertion & quantifiers), in line with `*`. But `!` is not
that intuitive after all and conflict with its role as section header.
Furthermore, `+` is also used as a merge mode. Finally, nothing beats
whole short words for readability.
test/data/rules/extended-wild-cards
! model = keycodes
* = evdev
! model = compat
* = complete
! model = types
* = complete
! model = symbols
* = pc
! layout[any] variant[any] = symbols
l1 <none> = +l10:%i // compatibity mapping: l1, no variant
l1 v1 = +l20:%i // compatibity mapping: l1, specific variant
l1 <some> = +l30%(v[%i]):%i // compatibity mapping: l1, some variant
l2 * = +l40%(v[%i]):%i // compatibity mapping: l2, some variant (legacy)
l3 <any> = +l50%(v[%i]):%i // compatibity mapping: l3, any variant (catch-all)
* v2 = +%l[%i](v20):%i // compatibity mapping: specific variant
* <any> = +%l[%i]%(v[%i]):%i // catch-all
! option = symbols
opt1 = +opt1