Repository navigation
bind: prefix-meta keymap bindings + inputrc old-style routing (Refs #2923 #2924) - #2993
Merged
Merged
Conversation
The old-style arm's `prefix-meta` value was stored verbatim as a function name, so `bind 'Control-t: prefix-meta'` occupied the slot but no submap row ever expanded. GNU intercepts the name in rl_parse_and_bind (lib/readline/bind.c:1845-1855, PREFIX_META_HACK) and binds the key to the emacs-meta keymap itself (rl_generic_bind ISKMAP, bind.c:1850). - BindingSpec/BindKind grow a Keymap variant; the parse arm emits it with the RAW key byte as the sequence (a META key spells \364, never an ESC decomposition - the C bypasses rl_bind_key). - BindRegistry learns keymap-valued slots (the defaults ESC->emacs-meta, C-x->emacs-ctlx, plus session Keymap registrations) and expands them recursively in invoking_keyseqs / macro_bindings, with a visited-path guard where GNU's unguarded scan segfaults. - A function/macro bound at a keymap-valued slot descends into the target map's ANYOTHERKEY fallback (rl_generic_bind's last-key arm): stored per target map, shared by every prefix, cleared by `bind -r` at any of the map's prefixes while the map itself stays bound. An ISKMAP bind discards the slot's previous function/macro outright. - Listing order: ANYOTHERKEY is the keymap array's last slot, so the bare prefix sorts after the submap's own rows (keyseq_scan_order). - The `read -e` editor table composes session bindings under a keymap prefix and fires the target fallback at the bare prefix. - BindView::capture renders the entry as Function "prefix-meta", exactly what hosts saw before; a faithful BindKindView::Keymap variant is a contract change, flagged in the lane report and deliberately not added here. Regression pins: tests/issue2923_bind_prefix_meta_keymap_regressions.rs (12 tests, GNU 5.3.20 oracle-verbatim; fail-first 10 red / 2 green on base b3e4ff8).
parse_inputrc_with_env only routed lines through the quoted-line parser and silently ignored everything else, so old-style keyname lines in `bind -f` files and the startup inputrc never landed - while the same specs bound fine as positional arguments. GNU feeds every inputrc line to rl_parse_and_bind (lib/readline/bind.c:2260), whose old-style arm (bind.c:1594) binds keyname specs exactly like quoted ones. The parser now routes a line the quoted parser does not claim through the existing parse_old_style_binding (rubash#2914), carrying the keymap stamp of the file's position and surfacing its diagnostics with file/line position. A latent gap found by the new pins, fixed in the same parser: `$if mode=emacs` never applied when no `set editing-mode` had run, because the conditional env carried None instead of readline's default editing mode (emacs - the variable table's own default; oracle: a bare `$if mode=emacs` block applies). The mode comparison now defaults an unset mode to emacs; the same fix covers quoted lines under mode conditionals. Regression pins: tests/issue2924_inputrc_old_style_binding_regressions.rs (8 tests, GNU 5.3.20 oracle-verbatim; fail-first on base: 8 red / 0 green; after: 8/8). Also covers the #2923 keymap value in files (`Control-t: prefix-meta` in an inputrc expands the meta map).
caomengxuan666
added a commit
to unixwin/niubash
that referenced
this pull request
Nov 7, 2026
…unixwin/rubash#2993) (#959) Merge per captain baseline adjudication: both red jobs on this PR (build-and-test alias host_contract test; macOS PTY S8) fail identically on master c5a7683 (run 42363951360, predating this PR) — failing name sets are identical branch vs base. Tracked for the alias test as a separate niu issue. The wildcard arm itself is verified locally against both rubash master and the rubash#2993 tree: cargo check rc=0, zero warnings, keymap pin 2/2 on both. 本 PR 删除了什么:无删除——仅在既有 match 上加一个通配臂与一条钉测试。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2923, Refs #2924 — two commits, one per issue (captain-filed residue of the #2921 batch).
Commit 1 — #2923
bind 'Control-t: prefix-meta'GNU intercepts
prefix-metain rl_parse_and_bind's old-style arm (lib/readline/bind.c:1845-1855) and binds the key to the emacs-meta keymap (ISKMAP); rubash stored the name verbatim as a function, so the slot was occupied but zero submap rows expanded. The registry now has a keymap-valuedBindKind, keymap-valued slots (defaults ESC→emacs-meta, C-x→emacs-ctlx, plus session registrations) expanded recursively by the dump/query paths, and the ANYOTHERKEY fallback mechanics of rl_generic_bind's last-key arm (a function/macro bound at a keymap slot becomes the target map's fallback, shared by all its prefixes;bind -rat a prefix clears only the fallback). No public Session surface added:BindViewrenders the entry asFunction "prefix-meta", exactly what hosts saw before — a faithfulBindKindView::Keymapvariant is a contract change, flagged for a separate decision in the lane report.Pins:
tests/issue2923_bind_prefix_meta_keymap_regressions.rs— 12 tests, GNU 5.3.20 oracle-verbatim (fail-first on base: 10 red / 2 green; after: 12/12).Commit 2 — #2924 inputrc old-style lines (follows on this branch)
parse_inputrc_with_envonly routed quoted lines; old-style keyname lines inbind -ffiles and the startup inputrc were silently dropped while the same specs bound fine as positional arguments. The parser now routes an unclaimed line through the existingparse_old_style_binding(rl_parse_and_bind's other arm), including its diagnostics with file/line position.UNVERIFIED-BY-CAPTAIN — lane self-checks in the lane REPORT; central re-verification pending.
本 PR 删除了什么
无删除。本 PR 是纯加法:新增
BindKind::Keymap/BindingSpec::Keymap变体、注册表fallbacks字段与递归展开、read -e编辑器表的键图展开;没有删除任何函数、测试、文件或公开符号,也没有移除任何既有行为(被取代的旧行为——prefix-meta按名逐字存储——是本单修复的 bug 本身,其回归钉见 commit 1 的新测试文件)。