removed work around for bug in s-exp reader and improved error message for user-defined keybindings in the wrong language

svn: r16296
This commit is contained in:
Robby Findler 2009-10-11 20:56:36 +00:00
parent 49e45e021b
commit 1203aaa886
2 changed files with 16 additions and 11 deletions

View File

@ -30,23 +30,27 @@
(parameterize ([read-accept-reader #t])
(call-with-input-file path read)))])
(match sexp
[`(module ,name ,(? valid-keybindings-lang?)
[`(module ,name ,lang
,@(x ...))
(let ([km (dynamic-require spec '#%keymap)])
(hash-set! user-keybindings-files spec km)
(send user-keymap chain-to-keymap km #t))]
(cond
[(valid-keybindings-lang? lang)
(let ([km (dynamic-require spec '#%keymap)])
(hash-set! user-keybindings-files spec km)
(send user-keymap chain-to-keymap km #t))]
[else
(error 'add-user-keybindings-file
(string-constant user-defined-keybinding-malformed-file/found-lang)
(path->string path)
lang)])]
[else (error 'add-user-keybindings-file
(string-constant user-defined-keybinding-malformed-file)
(path->string path))])))))
(define (valid-keybindings-lang? x)
(let ([valid-langs
(list `(lib "keybinding-lang.ss" "framework")
`(lib "framework/keybinding-lang.ss")
`framework/keybinding-lang)])
(cond
[(syntax? x) (member (syntax->datum x) valid-langs)]
[else (member x valid-langs)])))
(member x
(list `(lib "keybinding-lang.ss" "framework")
`(lib "framework/keybinding-lang.ss")
`framework/keybinding-lang)))
(define (spec->path p)
(cond

View File

@ -711,6 +711,7 @@ please adhere to these guidelines:
(user-defined-keybinding-error "Error running keybinding ~a\n\n~a")
(user-defined-keybinding-malformed-file "The file ~a does not contain a module written in the framework/keybinding-lang language.")
(user-defined-keybinding-malformed-file/found-lang "The file ~a does not contain a module written in the framework/keybinding-lang language. Instead, found the language ~s")
;; menu items in the "special" menu
(insert-text-box-item "Insert Text Box")