Skip to content

adjust use of qs-invalid-hook so that it gets used at runtime #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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