Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions script.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,7 @@
on-tab-close
on-startup
after-create-new-drracket-frame
on-close))
(define known-hook-ids-str
(apply string-append
(for*/list ([id known-hook-ids]
[s (in-list (list " " (symbol->string id) "\n"))])
s))))
on-close)))

(define-syntax (define-hook stx)
(syntax-parse stx
Expand Down Expand Up @@ -136,21 +131,25 @@
#:defaults ([os-types-val #'(unix macosx windows)])))
...
rhs:expr)
#:fail-when (and (not (memq (syntax-e #'proc)
known-hook-ids))
#'proc)
(string-append "Invalid hook name.\n Valid names:\n" known-hook-ids-str)
(add-submod-content!
#`(begin
(provide proc)
(define proc (list
(cons 'label #f)
(cons 'help-string 'help-string-val)
(cons 'persistent? '#,(attribute persist? #;persistent.persistent?))
(cons 'os-types 'os-types-val)))))
(syntax/loc stx
(begin (provide proc)
(define proc rhs)))]))
(cond
[(not (memq (syntax-e #'proc)
known-hook-ids))
#`(string-append (string-constant qs-invalid-hook)
#,@(for*/list ([id known-hook-ids]
[s (in-list (list " " (symbol->string id) "\n"))])
s))]
[else
(add-submod-content!
#`(begin
(provide proc)
(define proc (list
(cons 'label #f)
(cons 'help-string 'help-string-val)
(cons 'persistent? '#,(attribute persist? #;persistent.persistent?))
(cons 'os-types 'os-types-val)))))
(syntax/loc stx
(begin (provide proc)
(define proc rhs)))])]))

(define-syntax (generate-submodule stx)
#`(module script-info racket/base #,@submodule-content)
Expand Down