Commit 08be4c9
authored
PR: Unassigned allowed commands (ipython#14564)
From git git:
> Modify binding mechanism to allow binding to one of a set of
whitelisted commands, Add five such commands ("beginning_of_buffer",
"end_of_buffer", "end_of_line", "forward_word", "unix_line_discard").
Currently, only commands which are assigned by default are allowed to be
reassigned:
```python
known_commands = {
create_identifier(binding.command): binding.command
for binding in KEY_BINDINGS
}
...
if command_id not in known_commands:
...
raise ValueError(
f"{command_id} is not a known shortcut command."
f" Allowed commands are: \n - {allowed_commands}"
)
```
This PR adds a List UNASSIGNED_ALLOWED_COMMANDS and updates
`known_commands` (now renamed to be more clear as `allowed_commands`):
```python
allowed_commands.update({
create_identifier(command): command
for command in UNASSIGNED_ALLOWED_COMMANDS
})
```
The five unassigned allowed commands are:
```python
UNASSIGNED_ALLOWED_COMMANDS = [
nc.beginning_of_buffer,
nc.end_of_buffer,
nc.end_of_line,
nc.forward_word,
nc.unix_line_discard,
]
```
Motivation tldr: Until now, it is not possible to bind eg the common
keybindng `ctrl+e` to prompt_toolkit's `end_of_line` (because it is not
bound by default).
Full motivation: ipython#143692 files changed
+29
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
508 | 509 | | |
509 | 510 | | |
510 | 511 | | |
511 | | - | |
512 | | - | |
513 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
517 | 524 | | |
518 | 525 | | |
519 | 526 | | |
520 | 527 | | |
521 | 528 | | |
522 | | - | |
523 | | - | |
| 529 | + | |
| 530 | + | |
524 | 531 | | |
525 | 532 | | |
526 | 533 | | |
| |||
544 | 551 | | |
545 | 552 | | |
546 | 553 | | |
547 | | - | |
| 554 | + | |
548 | 555 | | |
549 | 556 | | |
550 | 557 | | |
| |||
586 | 593 | | |
587 | 594 | | |
588 | 595 | | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
595 | 604 | | |
596 | 605 | | |
597 | 606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
0 commit comments