Skip to content

Add a command to open macro stepper for selected syntax - #148

Merged
jryans merged 7 commits into
Eugleo:masterfrom
dannypsnl:invoke-macro-stepper
Sep 6, 2025
Merged

jryans merged 7 commits into
Eugleo:masterfrom
dannypsnl:invoke-macro-stepper

Conversation

@dannypsnl

@dannypsnl dannypsnl commented Sep 4, 2025 •

Copy link
Copy Markdown
Contributor

Add a command magic-racket.openMacroStepper which will send

(require macro-debugger/stepper)
;; and then
(expand/step #'syntax)

to REPL to execute (then this will open macro stepper GUI).

Also keybinding to Alt+Shift+Enter

This is originally a racket language server issue jeapostrophe/racket-langserver#145, but I think magic racket can have this immediately by open Racket GUI.

@dannypsnl

Copy link
Copy Markdown
Contributor Author

Screenshot

image image

@jryans

jryans commented Sep 4, 2025

Copy link
Copy Markdown
Collaborator

Seems like a nice initial approach! 😄 I'm happy to review further once you feel the PR is ready.

misc: rename to fit its meaning
Signed-off-by: Lîm Tsú-thuàn <inbox@dannypsnl.me>
Signed-off-by: Lîm Tsú-thuàn <inbox@dannypsnl.me>
@dannypsnl
dannypsnl marked this pull request as ready for review September 4, 2025 14:01
@dannypsnl dannypsnl changed the title Add a command to expand macro steps of selected syntax Add a command to open macro stepper for selected syntax Sep 4, 2025
@jryans

jryans commented Sep 5, 2025

Copy link
Copy Markdown
Collaborator

Ah, I see it's ready to review now. I'll aim to take a look in the next few days. 😄

(I wish GitHub sent email notifications when PRs changed to ready state...!)

@jryans jryans left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! 😄 It's quite nice to have a way to launch the macro stepper like this. I've made a few suggestions below.

(I fixed the CI workflows on master, so if you rebase your branch, you should see the workflows pass next time.)

Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread src/commands.ts
export function openMacroStepper(repls: Map<string, vscode.Terminal>): void {
withEditor((editor: vscode.TextEditor) => {
withFilePath((filePath: string) => {
withREPL((command: string[]) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to use withRacket instead of withREPL for this feature. When you use REPL, the REPL session is left open even after closing the macro stepper. If you use the "plain" Racket command, you can send your macro stepper instructions via several --eval options.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would need to escape characters in terminal, and I'm not sure if that's possible for all syntax, e.g.

racket --eval "(expand/step #'(define f (latex-lambda (x y) "x^2 + y^2")))"

got

string::26: read: expected a `)` to close `(`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess it is fairly annoying to properly shell-escape all possible expressions...

Maybe there's some way to watch an event fired by closing the stepper and then terminate the REPL? Anyway, we can improve that separately from this PR. I don't want to block on this.

Comment thread package.json Resolved
@dannypsnl
dannypsnl requested a review from jryans September 6, 2025 11:32

@jryans jryans left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me! 😄

Comment thread src/commands.ts
export function openMacroStepper(repls: Map<string, vscode.Terminal>): void {
withEditor((editor: vscode.TextEditor) => {
withFilePath((filePath: string) => {
withREPL((command: string[]) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess it is fairly annoying to properly shell-escape all possible expressions...

Maybe there's some way to watch an event fired by closing the stepper and then terminate the REPL? Anyway, we can improve that separately from this PR. I don't want to block on this.

@jryans
jryans merged commit 4b79e9e into Eugleo:master Sep 6, 2025
@jryans

jryans commented Sep 6, 2025

Copy link
Copy Markdown
Collaborator

I'll plan to release a new version in a few days time... Perhaps we'll find a better way to close the REPL before that release happens. Thanks again! 😄

@dannypsnl
dannypsnl deleted the invoke-macro-stepper branch September 6, 2025 23:13
@jryans

jryans commented Oct 14, 2025

Copy link
Copy Markdown
Collaborator

Just published version 0.8.0 with this, thanks again for working on it! 😄

@dannypsnl

Copy link
Copy Markdown
Contributor Author

NOTE: There is a LSP method called workspace/executeCommand, it seems can send very creative command to language server, including expand/step on given code, and hence avoid escape problems in terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants