Skip to content

Commit 7300611

Browse files
rfourquetKristofferC
authored andcommitted
REPL: fix/add doc for \\M- and \\C- key specifiers (#33771)
1 parent 810f8df commit 7300611

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

stdlib/REPL/docs/src/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ to do so), or pressing Esc and then the key.
181181
Julia's REPL keybindings may be fully customized to a user's preferences by passing a dictionary
182182
to `REPL.setup_interface`. The keys of this dictionary may be characters or strings. The key
183183
`'*'` refers to the default action. Control plus character `x` bindings are indicated with `"^x"`.
184-
Meta plus `x` can be written `"\\Mx"`. The values of the custom keymap must be `nothing` (indicating
185-
that the input should be ignored) or functions that accept the signature `(PromptState, AbstractREPL, Char)`.
184+
Meta plus `x` can be written `"\\M-x"` or `"\ex"`, and Control plus `x` can be written
185+
`"\\C-x"` or `"^x"`.
186+
The values of the custom keymap must be `nothing` (indicating
187+
that the input should be ignored) or functions that accept the signature
188+
`(PromptState, AbstractREPL, Char)`.
186189
The `REPL.setup_interface` function must be called before the REPL is initialized, by registering
187190
the operation with [`atreplinit`](@ref) . For example, to bind the up and down arrow keys to move through
188191
history without prefix search, one could put the following code in `~/.julia/config/startup.jl`:

stdlib/REPL/src/LineEdit.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,12 +1295,12 @@ function normalize_key(key::AbstractString)
12951295
c, i = iterate(key, i)
12961296
if c == 'C'
12971297
c, i = iterate(key, i)
1298-
@assert c == '-'
1298+
c == '-' || error("the Control key specifier must start with \"\\\\C-\"")
12991299
c, i = iterate(key, i)
13001300
write(buf, uppercase(c)-64)
13011301
elseif c == 'M'
13021302
c, i = iterate(key, i)
1303-
@assert c == '-'
1303+
c == '-' || error("the Meta key specifier must start with \"\\\\M-\"")
13041304
c, i = iterate(key, i)
13051305
write(buf, '\e')
13061306
write(buf, c)

0 commit comments

Comments
 (0)