mihaiolteanu / mugur

Configurator for QMK compatible keyboards

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check keymaps lengths from mugur

nico202 opened this issue · comments

Hi! I was working on this to have better error reporting to the user when a keymap has too much/too few items.

I see two approaches here: have a variable with the expected number of items, or guess which is wrong based on the items in all keymaps (if 2 have length 62 and one 63, report this one as probably wrong).

Which approach do you prefer? The second one require less setup but is a guesswork (can't work with only 1 layer, can report useless errors when there are 2 (one of them is wrong, but which one) and might work for more layers). The first approach requires a new defcustom.

Also, is it fine to throw a error since it's not possible for a keymap can have a different number of keys, right?

It's also possible to have both: if the variable is nil, fallback to guess, else use it, but maybe just adding extra complexity

Checking the length of the keymaps was one of the reasons, among others, for mugur v1.0 not supporting all qmk keyboards by default.

Yes, this is extra complexity, as you would have to hard-code the number of keys for each and every keyboard out there. So I would prefer no to check this with the downside that the user will have to actually count the number of keys for his keyboard but with the benefit of mugur being usable, in principle, for any keyboard.

Best case scenario, maybe have a wiki article with ergodox, moonlander, etc layouts, that the user can just copy/paste into his configuration. Maybe that would be (more) useful.

I get it, but what about something non intrusive like this?
master...nico202:check-length

It shouldn't harm those not wanting to use it, but still provide some insight on possible problems.
Let me know

I maintain my initial opinion about this.

If you're using smartparens, sp-wrap-round adds a new pair of parens around the expression at point (our layer, in this case). length then takes care of counting the number of keys in that layer for you. Each new layer after that is a sp-copy-sexp of this layer.

(a b c d e)                 ;layer of keys
((a b c d e))               ;after sp-wrap-around
(length '(a b c d e))       ;add length
(length '(a b c d e)) --> 5 ;evaluate the resulting expression
(length '(a b c d e f))     ;we actually wanted 6 keys, so add another item
(length '(a b c d e f))     ;set point on the start of the layer and use sp-raise-sexp
(a b c d e f)               ;final result

I maintain my initial opinion about this.

Ok fine!