From 1203aaa8861bca4fef0931790842289d147cc979 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 11 Oct 2009 20:56:36 +0000 Subject: [PATCH] removed work around for bug in s-exp reader and improved error message for user-defined keybindings in the wrong language svn: r16296 --- collects/framework/private/keymap.ss | 26 +++++++++++-------- .../english-string-constants.ss | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/collects/framework/private/keymap.ss b/collects/framework/private/keymap.ss index 9125865b58..acfbe10d1c 100644 --- a/collects/framework/private/keymap.ss +++ b/collects/framework/private/keymap.ss @@ -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 diff --git a/collects/string-constants/english-string-constants.ss b/collects/string-constants/english-string-constants.ss index 8d30f09617..1ef9a89cc9 100644 --- a/collects/string-constants/english-string-constants.ss +++ b/collects/string-constants/english-string-constants.ss @@ -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")