Commit c050c96
committed
refactor(keymap): one typed spine taxonomy, fixing inline-vector bindings
The shapes a keymap element can take -- `(KEY . BINDING)` cons, inline vector,
char-table, composed submap, parent, prompt string -- were re-decoded ad-hoc at
four separate sites, and the copies had drifted. Two iterators in keymap.rs
disagreed: `list_keymap_for_each_binding_recursive` handled inline vectors while
`list_keymap_for_each_binding` (the one the `where-is-internal` reverse scan
uses) did not, so a command bound through a vector was unreachable by
`where-is-internal` even though `lookup-key` found it:
(let* ((v (make-vector 128 nil)) (m (list 'keymap v)))
(aset v ?a 'cmd)
(list (lookup-key m "a") ; => cmd both
(where-is-internal 'cmd (list m) t))) ; => nil neomacs
; [97] GNU
That same drift is what made the #164 dashboard leader hints vanish (three
separate sites each missing a different shape). So decode the union once:
KeymapElement::{ Binding{key,value} | Submap | IndirectTail | Prompt }
`for_each_keymap_element` mirrors GNU `map_keymap_internal` exactly -- including
the inline-vector arm and `map_keymap_item`'s `t`-value -> nil normalization (a
`t` binding is an explicit unbinding, not a binding of the symbol `t`). It yields
`Submap` instead of descending, so each consumer keeps its own descent policy;
GNU `map_keymap` treats composed submaps and the parent identically, hence one
variant for both.
Rebuilt on it: `list_keymap_for_each_binding`, its recursive variant, and
`keymap_prompt_scan` (a fourth hand-rolled copy). Now `match` exhaustiveness
makes a missed shape a compile error rather than a silent nil.
`IndirectTail` is a typed known gap: GNU resolves a symbol spine tail via
get_keymap, neomacs resolves it nowhere, so lookup-key and where-is-internal
both return nil where GNU finds the binding. Fixing it means plumbing an
&Obarray through the forward lookup chain; doing only the reverse side would make
the two disagree, which is worse than today's consistent miss. Typed so it is
visible instead of silently skipped.
Verified against GNU 31 across every element kind (vector, char-table, `(t .
DEF)` default, nested vector, composed submap): identical results. 184 keymap /
menu / where-is / TTY-menu tests pass across both crates; 20 keymap oracle cases
pass, including a new inline-vector parity case.1 parent 713a9ce commit c050c96
5 files changed
Lines changed: 296 additions & 82 deletions
File tree
- neovm-core/src/emacs_core
- builtins
- neovm-oracle-tests/src/divergence
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6358 | 6358 | | |
6359 | 6359 | | |
6360 | 6360 | | |
6361 | | - | |
6362 | | - | |
6363 | | - | |
6364 | | - | |
6365 | | - | |
6366 | | - | |
6367 | | - | |
6368 | | - | |
6369 | | - | |
6370 | | - | |
6371 | | - | |
6372 | | - | |
6373 | | - | |
6374 | | - | |
6375 | | - | |
6376 | | - | |
6377 | | - | |
6378 | | - | |
| 6361 | + | |
| 6362 | + | |
| 6363 | + | |
| 6364 | + | |
| 6365 | + | |
| 6366 | + | |
| 6367 | + | |
| 6368 | + | |
| 6369 | + | |
| 6370 | + | |
| 6371 | + | |
| 6372 | + | |
| 6373 | + | |
| 6374 | + | |
| 6375 | + | |
| 6376 | + | |
| 6377 | + | |
| 6378 | + | |
| 6379 | + | |
| 6380 | + | |
| 6381 | + | |
6379 | 6382 | | |
| 6383 | + | |
6380 | 6384 | | |
6381 | | - | |
6382 | | - | |
6383 | | - | |
| 6385 | + | |
| 6386 | + | |
6384 | 6387 | | |
6385 | 6388 | | |
6386 | 6389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4734 | 4734 | | |
4735 | 4735 | | |
4736 | 4736 | | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
| 4742 | + | |
| 4743 | + | |
| 4744 | + | |
| 4745 | + | |
| 4746 | + | |
| 4747 | + | |
| 4748 | + | |
| 4749 | + | |
| 4750 | + | |
| 4751 | + | |
| 4752 | + | |
| 4753 | + | |
| 4754 | + | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
4737 | 4758 | | |
4738 | 4759 | | |
4739 | 4760 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3446 | 3446 | | |
3447 | 3447 | | |
3448 | 3448 | | |
3449 | | - | |
3450 | | - | |
3451 | | - | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
3452 | 3518 | | |
3453 | | - | |
| 3519 | + | |
3454 | 3520 | | |
3455 | 3521 | | |
3456 | 3522 | | |
3457 | 3523 | | |
| 3524 | + | |
3458 | 3525 | | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
3459 | 3532 | | |
3460 | | - | |
| 3533 | + | |
| 3534 | + | |
3461 | 3535 | | |
3462 | | - | |
3463 | | - | |
3464 | 3536 | | |
3465 | | - | |
3466 | | - | |
3467 | | - | |
| 3537 | + | |
| 3538 | + | |
3468 | 3539 | | |
3469 | | - | |
3470 | | - | |
3471 | | - | |
3472 | | - | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
3473 | 3569 | | |
3474 | 3570 | | |
3475 | | - | |
3476 | | - | |
3477 | | - | |
3478 | | - | |
| 3571 | + | |
3479 | 3572 | | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
3480 | 3592 | | |
3481 | 3593 | | |
3482 | 3594 | | |
| |||
3494 | 3606 | | |
3495 | 3607 | | |
3496 | 3608 | | |
3497 | | - | |
| 3609 | + | |
3498 | 3610 | | |
3499 | 3611 | | |
3500 | | - | |
3501 | | - | |
3502 | | - | |
3503 | | - | |
3504 | | - | |
3505 | | - | |
3506 | | - | |
3507 | | - | |
3508 | | - | |
3509 | | - | |
3510 | | - | |
3511 | | - | |
3512 | | - | |
3513 | | - | |
3514 | | - | |
3515 | | - | |
3516 | | - | |
3517 | | - | |
3518 | | - | |
3519 | | - | |
3520 | | - | |
3521 | | - | |
3522 | | - | |
3523 | | - | |
3524 | | - | |
3525 | | - | |
3526 | | - | |
3527 | | - | |
3528 | | - | |
3529 | | - | |
3530 | | - | |
3531 | | - | |
3532 | | - | |
3533 | | - | |
3534 | | - | |
3535 | | - | |
3536 | | - | |
3537 | | - | |
3538 | | - | |
3539 | | - | |
3540 | | - | |
3541 | | - | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
| 3620 | + | |
3542 | 3621 | | |
3543 | 3622 | | |
3544 | 3623 | | |
| |||
0 commit comments