I was wondering how to let racket-mode
handle racket language extensions properly?
I tried the following file from the link above (test.rkt
):
#lang datalog
ancestor(A, B) :- parent(A, B).
ancestor(A, B) :-
parent(A, C), D = C, ancestor(D, B).
parent(john, douglas).
parent(bob, john).
ancestor(A, B)?
After C-c C-z
, (which launches the REPL with ; Welcome to Racket v8.5 [cs]...
),
I was able to load the extension if I send the whole buffer (C-c C-c
, or racket-run-module-at-point
) to the REPL.
>
ancestor(bob, john).
ancestor(john, douglas).
ancestor(bob, douglas).
test.rkt>
; Closing REPL session because language's current-read-interaction returned EOF
Process *Racket REPL </>* connection broken by remote peer
But I cannot execute individual regions (and the REPL is terminated). If I just do C-c C-r
(racket-send-region
) on the first line (or few lines), including the #lang
directive, I get an error:
; :2:0: read-syntax: `#lang` not enabled
; possible reason: not allowed again inside a module that already starts `#lang`, or not enabled for interactive evaluation
; datalog: undefined;
; cannot reference an identifier before its definition
; in module: top-level
>
How to configure Emacs racket-mode in order to make racket-send-region
work in above?
(This is with Emacs 28, racket-mode from MELPA, under Ubuntu 22.04 LTS)