From aefdab63078b4083cdd8ecfb26e5ef5e4ffe2db8 Mon Sep 17 00:00:00 2001 From: Matt Paras Date: Fri, 23 May 2025 06:42:14 -0700 Subject: [PATCH] fix arity on acquire-context-lock --- helix-term/src/commands/engine/steel.rs | 53 +++++++++++++++++-------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/helix-term/src/commands/engine/steel.rs b/helix-term/src/commands/engine/steel.rs index 8f52e7b4d..b74e4d67e 100644 --- a/helix-term/src/commands/engine/steel.rs +++ b/helix-term/src/commands/engine/steel.rs @@ -3277,30 +3277,26 @@ callback : (-> any?) ); } - let mut template_function_arity_2 = |name: &str, doc: &str| { - if generate_sources { - let doc = format_docstring(doc); - builtin_misc_module.push_str(&format!( - r#" + macro_rules! register_2_no_context { + ($name:expr, $func:expr, $doc:expr) => {{ + module.register_fn($name, $func); + if generate_sources { + let doc = format_docstring($doc); + builtin_misc_module.push_str(&format!( + r#" (provide {}) ;;@doc {} (define ({} arg1 arg2) - (helix.{} *helix.cx* arg1 arg2)) + (helix.{} arg1 arg2)) "#, - name, doc, name, name - )); - } - }; - - macro_rules! register_2 { - ($name:expr, $func:expr, $doc:expr) => {{ - module.register_fn($name, $func); - template_function_arity_2($name, $doc); + $name, doc, $name, $name + )); + } }}; } - register_2!( + register_2_no_context!( "acquire-context-lock", |callback_fn: SteelVal, place: Option| { match (&callback_fn, &place) { @@ -3383,7 +3379,7 @@ The provided function will get enqueued to run on the main thread, and during th execution, the provided mutex will be locked. ```scheme -(acquire-context-lock? callback-fn mutex) +(acquire-context-lock callback-fn mutex) ``` callback-fn : (-> void?) @@ -3393,6 +3389,29 @@ mutex : mutex? "# ); + let mut template_function_arity_2 = |name: &str, doc: &str| { + if generate_sources { + let doc = format_docstring(doc); + builtin_misc_module.push_str(&format!( + r#" +(provide {}) +;;@doc +{} +(define ({} arg1 arg2) + (helix.{} *helix.cx* arg1 arg2)) +"#, + name, doc, name, name + )); + } + }; + + macro_rules! register_2 { + ($name:expr, $func:expr, $doc:expr) => {{ + module.register_fn($name, $func); + template_function_arity_2($name, $doc); + }}; + } + // Arity 2 register_2!( "enqueue-thread-local-callback-with-delay",