
@christophe.scholliers has joined the channel

scribble problem: I want something like codeblock
, but that typesets the contents of a file. The attachment here has a macroracketfile
that gets close, but doesn’t get links right (i.e. if you unzip and run make
, the first +
in main.html
isn’t blue). Any ideas on how to get it working?

I seem to have the following macro in my Fundies utilities file; it might help? (define-syntax (scheme-from-file stx)
(syntax-case stx ()
[(_ fname #:start start #:end end)
(let* ([l (extract-from-file (syntax-e #'fname)
(syntax-e #'start)
(if (eq? (syntax-e #'end) 'same)
(syntax-e #'start)
(syntax-e #'end)))])
#`(scr:codeblock #:indent 0 #,(datum->syntax stx (car l)) #,@(cdr l)))]))

with, evidently, this as a helper: (define-for-syntax (extract-from-file filename start end)
(parameterize ([read-accept-reader #t])
(call-with-input-file filename
(λ (port)
(let loop ([in? #f])
(let ([l (read-line port 'any)])
(cond
[(eof-object? l)
'()]
[(and (not in?)
(regexp-match start l)
(regexp-match end l))
(list l "\n")]
[(and (not in?) (regexp-match start l))
(check-tab l filename)
(list* l "\n" (loop #t))]
[(and in? (regexp-match end l))
(check-tab l filename)
(list l "\n")]
[in?
(check-tab l filename)
(list* l "\n" (loop #t))]
[else
(loop #f)])))))))

(check-tab is boring, and just complains if there are tabs in the file. you could simplify that extract-from-file by a lot, I’m guessing)

Thank you! (Changing my code from (codeblock #,@stuff)
to (codeblock #,(datum->syntax stx (car stuff)) #,@(cdr stuff))
fixed it)

@felix has joined the channel

@mflatt @michael.ballantyne I think I may have found a case in which implementing syntax parameters using phase 1 parameters + local expansion causes my code to work on Racket 6.12 but not Racket 7.


Full disclosure, I only wrote the program that Racket 7 breaks tonight, so it’s not like I have existing code that was broken by the change. It seems unlikely much code that depends on the old behavior exists, but I’d still like to be able to use syntax-parameterize
here, so if it isn’t valid as a bug report, consider it a feature request.