From 83d74bcd8b10034bc2af9e39bf46ac2bb26989ac Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 30 Nov 2021 12:45:18 -0700 Subject: [PATCH] (awaitCommands) macro --- projects/kiss-vscode/src/Util.kiss | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/projects/kiss-vscode/src/Util.kiss b/projects/kiss-vscode/src/Util.kiss index c6d895b6..f0024fcd 100644 --- a/projects/kiss-vscode/src/Util.kiss +++ b/projects/kiss-vscode/src/Util.kiss @@ -38,6 +38,19 @@ (set promise (promise.then iteration))) promise)) +(defMacro awaitCommands [commandsAndArgs &builder b &body body] + (let [commandsAndArgs + (if (isListExp commandsAndArgs) + (.copy (expList commandsAndArgs)) + (throw (CompileError.fromExp commandsAndArgs "First argument to awaitCommands should be a list of commands with optional argument arrays"))) + bindings []] + (while commandsAndArgs + (bindings.push (b.symbol "_")) + (let [nextCommand (commandsAndArgs.shift)] + (bindings.push (b.callSymbol "executeCommand" + (concat [nextCommand] (if (and commandsAndArgs (isListExp (first commandsAndArgs))) (expList (commandsAndArgs.shift)) [])))))) + `(awaitLet ,bindings ,@body))) + // Other (defAlias &call showTextDocument Vscode.window.showTextDocument)