summaryrefslogtreecommitdiffstats
path: root/src/prompt_toolkit/key_binding/bindings/emacs.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 04:45:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 04:45:15 +0000
commit6dc655898df34ad424dfc467a8b276fdf31bd791 (patch)
tree0a3f3addbfc0b81e3850a628afe62ce830a8b0f3 /src/prompt_toolkit/key_binding/bindings/emacs.py
parentReleasing progress-linux version 3.0.43-2~progress7.99u1. (diff)
downloadprompt-toolkit-6dc655898df34ad424dfc467a8b276fdf31bd791.tar.xz
prompt-toolkit-6dc655898df34ad424dfc467a8b276fdf31bd791.zip
Merging upstream version 3.0.46.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/prompt_toolkit/key_binding/bindings/emacs.py')
-rw-r--r--src/prompt_toolkit/key_binding/bindings/emacs.py16
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")