diff options
Diffstat (limited to 'src/prompt_toolkit/key_binding/bindings/emacs.py')
-rw-r--r-- | src/prompt_toolkit/key_binding/bindings/emacs.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/prompt_toolkit/key_binding/bindings/emacs.py b/src/prompt_toolkit/key_binding/bindings/emacs.py index 80a66fd..207afba 100644 --- a/src/prompt_toolkit/key_binding/bindings/emacs.py +++ b/src/prompt_toolkit/key_binding/bindings/emacs.py @@ -33,6 +33,16 @@ __all__ = [ E = KeyPressEvent +@Condition +def is_returnable() -> bool: + return get_app().current_buffer.is_returnable + + +@Condition +def is_arg() -> bool: + return get_app().key_processor.arg == "-" + + def load_emacs_bindings() -> KeyBindingsBase: """ Some e-macs extensions. @@ -134,7 +144,7 @@ def load_emacs_bindings() -> KeyBindingsBase: if event._arg is None: event.append_to_arg_count("-") - @handle("-", filter=Condition(lambda: get_app().key_processor.arg == "-")) + @handle("-", filter=is_arg) def _dash(event: E) -> None: """ When '-' is typed again, after exactly '-' has been given as an @@ -142,10 +152,6 @@ def load_emacs_bindings() -> KeyBindingsBase: """ event.app.key_processor.arg = "-" - @Condition - def is_returnable() -> bool: - return get_app().current_buffer.is_returnable - # Meta + Enter: always accept input. handle("escape", "enter", filter=insert_mode & is_returnable)( get_by_name("accept-line") |