From 6dc655898df34ad424dfc467a8b276fdf31bd791 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 5 Jun 2024 06:45:15 +0200 Subject: Merging upstream version 3.0.46. Signed-off-by: Daniel Baumann --- src/prompt_toolkit/key_binding/bindings/emacs.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/prompt_toolkit/key_binding/bindings/emacs.py') 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") -- cgit v1.2.3