diff --git a/drracket-core-lib/drracket/private/module-language-tools.rkt b/drracket-core-lib/drracket/private/module-language-tools.rkt index e7a7fd796..d27eb4543 100644 --- a/drracket-core-lib/drracket/private/module-language-tools.rkt +++ b/drracket-core-lib/drracket/private/module-language-tools.rkt @@ -589,15 +589,12 @@ (send (send frame get-toolbar-button-panel) change-children (λ (prev) '())) (define directly-specified-buttons - (map (λ (button-spec) - (new switchable-button% - [label (list-ref button-spec 0)] - [bitmap (list-ref button-spec 1)] - [parent (send frame get-toolbar-button-panel)] - [callback - (lambda (button) - ((list-ref button-spec 2) frame))])) - cleaned-up-buttons)) + (for/list ([button-spec (in-list cleaned-up-buttons)]) + (new switchable-button% + [label (list-ref button-spec 0)] + [bitmap (list-ref button-spec 1)] + [parent (send frame get-toolbar-button-panel)] + [callback (lambda (button) ((list-ref button-spec 2) frame))]))) (define directly-specified-button-numbers (map (λ (button-spec) (list-ref button-spec 3)) cleaned-up-buttons)) @@ -725,8 +722,7 @@ (define tmp-b (box #f)) (define fn (get-filename tmp-b)) (when (unbox tmp-b) (set! fn #f)) - (define the-dir (get-init-dir fn)) - the-dir) + (get-init-dir fn)) (super-new) @@ -818,16 +814,15 @@ (error who "no more online-expansion-handlers can be registered; got ~e ~e ~e" mod-path id local-handler)) - (for ([handler (in-list online-expansion-handlers)]) - (when (and (equal? (online-expansion-handler-mod-path handler) mod-path) - (equal? (online-expansion-handler-id handler) id)) - (error who - (string-append - "already registered a handler with the same mod-path and id\n" - " mod-path: ~e\n" - " id: ~e") - mod-path - id)))) + (for ([handler (in-list online-expansion-handlers)] + #:when (and (equal? (online-expansion-handler-mod-path handler) mod-path) + (equal? (online-expansion-handler-id handler) id))) + (error who + (string-append "already registered a handler with the same mod-path and id\n" + " mod-path: ~e\n" + " id: ~e") + mod-path + id))) (define online-expansion-pref-funcs '()) (define (get-online-expansion-pref-funcs) online-expansion-pref-funcs) @@ -841,24 +836,18 @@ ;; saving a file in Windows (define (move-extension-first ext filters) (define rx (regexp (string-append "(?:^|;)[*][.]" ext "(?:$|;)"))) - (map (lambda (p) - (define exts (cadr p)) - (define m (regexp-match-positions rx exts)) - (if m - (list (car p) - (string-append (string-append "*." ext) - (if (or ((caar m) . > . 0) - ((cdar m) . < . (string-length exts))) - ";" - "") - (substring exts 0 (caar m)) - (if (and ((caar m) . > . 0) - ((cdar m) . < . (string-length exts))) - ";" - "") - (substring exts (cdar m)))) - p)) - filters)) + (for/list ([p (in-list filters)]) + (define exts (cadr p)) + (define m (regexp-match-positions rx exts)) + (if m + (list (car p) + (string-append + (string-append "*." ext) + (if (or ((caar m) . > . 0) ((cdar m) . < . (string-length exts))) ";" "") + (substring exts 0 (caar m)) + (if (and ((caar m) . > . 0) ((cdar m) . < . (string-length exts))) ";" "") + (substring exts (cdar m)))) + p))) (module+ test (check-equal? (move-extension-first diff --git a/drracket-core-lib/drracket/private/module-language.rkt b/drracket-core-lib/drracket/private/module-language.rkt index 80aef745a..cdba167ec 100644 --- a/drracket-core-lib/drracket/private/module-language.rkt +++ b/drracket-core-lib/drracket/private/module-language.rkt @@ -259,17 +259,20 @@ ;; in other languages (here 'none is the default annotations, ;; there you get errortrace annotations). (define/override (default-settings) - (let ([super-defaults (super default-settings)]) - (make-module-language-settings - #t 'print 'mixed-fraction-e #f #t 'debug;; simple settings defaults - - '(default) - #() - #f ;; auto-text is ignored now - default-compilation-on? - default-full-trace? - default-submodules-to-run - default-enforce-module-constants))) + (super default-settings) + (make-module-language-settings #t + 'print + 'mixed-fraction-e + #f + #t + 'debug ;; simple settings defaults + '(default) + #() + #f ;; auto-text is ignored now + default-compilation-on? + default-full-trace? + default-submodules-to-run + default-enforce-module-constants)) ;; default-settings? : -> boolean (define/override (default-settings? settings) @@ -294,15 +297,15 @@ default-enforce-module-constants))) (define/override (marshall-settings settings) - (let ([super-marshalled (super marshall-settings settings)]) - (list super-marshalled - (module-language-settings-collection-paths settings) - (module-language-settings-command-line-args settings) - (module-language-settings-auto-text settings) - (module-language-settings-compilation-on? settings) - (module-language-settings-full-trace? settings) - (module-language-settings-submodules-to-run settings) - (module-language-settings-enforce-module-constants settings)))) + (define super-marshalled (super marshall-settings settings)) + (list super-marshalled + (module-language-settings-collection-paths settings) + (module-language-settings-command-line-args settings) + (module-language-settings-auto-text settings) + (module-language-settings-compilation-on? settings) + (module-language-settings-full-trace? settings) + (module-language-settings-submodules-to-run settings) + (module-language-settings-enforce-module-constants settings))) (define/override (unmarshall-settings marshalled) (and (list? marshalled) @@ -369,13 +372,12 @@ (define/override (on-execute settings run-in-user-thread) (super on-execute settings run-in-user-thread) - (let ([currently-open-files (get-currently-open-files)]) - (run-in-user-thread - (λ () - (set-module-language-parameters - (module-language-settings->prefab-module-settings settings) - module-language-parallel-lock-client - currently-open-files))))) + (define currently-open-files (get-currently-open-files)) + (run-in-user-thread (λ () + (set-module-language-parameters + (module-language-settings->prefab-module-settings settings) + module-language-parallel-lock-client + currently-open-files)))) (define/override (get-one-line-summary) (string-constant module-language-one-line-summary)) @@ -385,11 +387,16 @@ ;; included; when done with the list, send eof. (define (expr-getter . exprs/thunks) (define (loop) - (if (null? exprs/thunks) - eof - (let ([x (car exprs/thunks)]) - (set! exprs/thunks (cdr exprs/thunks)) - (if (procedure? x) (begin (x) (loop)) x)))) + (cond + [(null? exprs/thunks) eof] + [else + (define x (car exprs/thunks)) + (set! exprs/thunks (cdr exprs/thunks)) + (if (procedure? x) + (begin + (x) + (loop)) + x)])) loop) (inherit get-reader) @@ -500,15 +507,11 @@ (queue-callback (λ () (set-irl-mcli-vec! the-irl info))))) (when info - (let ([get-info - ((dynamic-require (vector-ref info 0) - (vector-ref info 1)) - (vector-ref info 2))]) - (let ([configs (get-info 'configure-runtime '())]) - (for ([config (in-list configs)]) - ((dynamic-require (vector-ref config 0) - (vector-ref config 1)) - (vector-ref config 2)))))) + (define get-info + ((dynamic-require (vector-ref info 0) (vector-ref info 1)) (vector-ref info 2))) + (define configs (get-info 'configure-runtime '())) + (for ([config (in-list configs)]) + ((dynamic-require (vector-ref config 0) (vector-ref config 1)) (vector-ref config 2)))) (define cr-submod `(submod ,modspec configure-runtime)) (when (module-declared? cr-submod) (dynamic-require cr-submod #f))) @@ -527,13 +530,13 @@ ((current-read-interaction) (object-name port) port)))]) - (if (eof-object? v) - v - (let ([w (cons '#%top-interaction v)]) - (if (syntax? v) - (namespace-syntax-introduce - (datum->syntax #f w v)) - v)))))) + (cond + [(eof-object? v) v] + [else + (define w (cons '#%top-interaction v)) + (if (syntax? v) + (namespace-syntax-introduce (datum->syntax #f w v)) + v)])))) (define/override (render-value/format value settings port width) (do-print value settings port width)) @@ -548,74 +551,67 @@ ;; printer settings are just ignored here. (define/override (create-executable setting parent program-filename) - (let* ([executable-specs (drracket:language:create-executable-gui - parent program-filename #t #t)]) - (when executable-specs - (let ([executable-type (list-ref executable-specs 0)] - [gui? (eq? 'mred (list-ref executable-specs 1))] - [executable-filename (list-ref executable-specs 2)] - [aux (list-ref executable-specs 3)]) - (with-handlers ([(λ (x) #f) ;exn:fail? - (λ (x) - (message-box - (string-constant drscheme) - (if (exn? x) - (format "~a" (exn-message x)) - (format "uncaught exception: ~s" x))))]) - (let ([call-create-embedding-executable - (λ (exe-name) - (let ([short-program-name - (let-values ([(base name dir) (split-path program-filename)]) - (path-replace-suffix name #""))]) - (create-embedding-executable - exe-name - #:gracket? gui? - #:aux aux - #:verbose? #f - #:expand-namespace (make-base-namespace) - #:modules (list (list #f program-filename)) - #:configure-via-first-module? #t - #:literal-expression - (parameterize ([current-namespace (make-base-empty-namespace)]) - (namespace-require 'racket/base) - (compile - `(namespace-require - '',(string->symbol (path->string short-program-name))))) - #:cmdline '("-U" "--"))))]) - - (case executable-type - [(launcher) - (let ([make-launcher (if gui? make-mred-launcher make-mzscheme-launcher)]) - (make-launcher (list "-qt-" (path->string program-filename)) - executable-filename))] - [(distribution) - (drracket:language:create-distribution-for-executable - executable-filename - gui? - call-create-embedding-executable)] - [(stand-alone) - (define c (make-custodian)) - (define d (new dialog% - [parent parent] - [label (string-constant create-executable-title)])) - (new message% - [parent d] - [label (string-constant creating-executable-progress-status)]) - (new button% - [parent d] - [label (string-constant abort)] - [callback (lambda (_1 _2) - (custodian-shutdown-all c))]) - (define thd - (parameterize ([current-custodian c]) - (thread - (λ () - (call-create-embedding-executable executable-filename))))) - (thread - (λ () - (thread-wait thd) - (queue-callback (λ () (send d show #f))))) - (send d show #t)]))))))) + (define executable-specs + (drracket:language:create-executable-gui parent program-filename #t #t)) + (when executable-specs + (let ([executable-type (list-ref executable-specs 0)] + [gui? (eq? 'mred (list-ref executable-specs 1))] + [executable-filename (list-ref executable-specs 2)] + [aux (list-ref executable-specs 3)]) + (with-handlers (;exn:fail? + [(λ (x) #f) (λ (x) + (message-box (string-constant drscheme) + (if (exn? x) + (format "~a" (exn-message x)) + (format "uncaught exception: ~s" x))))]) + (let ([call-create-embedding-executable + (λ (exe-name) + (let ([short-program-name + (let-values ([(base name dir) (split-path program-filename)]) + (path-replace-suffix name #""))]) + (create-embedding-executable + exe-name + #:gracket? gui? + #:aux aux + #:verbose? #f + #:expand-namespace (make-base-namespace) + #:modules (list (list #f program-filename)) + #:configure-via-first-module? #t + #:literal-expression + (parameterize ([current-namespace (make-base-empty-namespace)]) + (namespace-require 'racket/base) + (compile `(namespace-require + '',(string->symbol (path->string short-program-name))))) + #:cmdline '("-U" "--"))))]) + + (case executable-type + [(launcher) + (let ([make-launcher (if gui? make-mred-launcher make-mzscheme-launcher)]) + (make-launcher (list "-qt-" (path->string program-filename)) + executable-filename))] + [(distribution) + (drracket:language:create-distribution-for-executable + executable-filename + gui? + call-create-embedding-executable)] + [(stand-alone) + (define c (make-custodian)) + (define d + (new dialog% [parent parent] [label (string-constant create-executable-title)])) + (new message% + [parent d] + [label (string-constant creating-executable-progress-status)]) + (new button% + [parent d] + [label (string-constant abort)] + [callback (lambda (_1 _2) (custodian-shutdown-all c))]) + (define thd + (parameterize ([current-custodian c]) + (thread (λ () (call-create-embedding-executable executable-filename))))) + (thread (λ () + (thread-wait thd) + (queue-callback (λ () (send d show #f))))) + (send d show #t)])))))) (super-new [module #f] @@ -633,7 +629,9 @@ ;; Throw an error as usual if we don't have the drracket rep, then we just ;; raise the exception as normal. (It can happen in some rare cases like ;; having a single empty scheme box in the definitions.) - (unless rep (if exn (raise exn) (error "\nInteractions disabled"))) + (unless rep (when exn + (raise exn)) + (error "\nInteractions disabled")) (when exn ((error-display-handler) (exn-message exn) exn)) ;; these are needed, otherwise the warning can appear before the output (flush-output (current-output-port)) @@ -805,19 +803,19 @@ (λ (x y) (move-callback +1) (something-changed)))) (define (update-buttons) - (let ([lb-selection (send collection-paths-lb get-selection)] - [lb-tot (send collection-paths-lb get-number)]) - (send remove-button enable lb-selection) - (send raise-button enable (and lb-selection (not (= lb-selection 0)))) - (send lower-button enable - (and lb-selection (not (= lb-selection (- lb-tot 1))))))) + (define lb-selection (send collection-paths-lb get-selection)) + (define lb-tot (send collection-paths-lb get-number)) + (send remove-button enable lb-selection) + (send raise-button enable (and lb-selection (not (= lb-selection 0)))) + (send lower-button enable (and lb-selection (not (= lb-selection (- lb-tot 1)))))) (define (add-callback) - (let ([dir (get-directory (string-constant ml-cp-choose-a-collection-path) - (send parent get-top-level-window))]) - (when dir - (send collection-paths-lb append (path->string dir) #f) - (update-buttons)))) + (define dir + (get-directory (string-constant ml-cp-choose-a-collection-path) + (send parent get-top-level-window))) + (when dir + (send collection-paths-lb append (path->string dir) #f) + (update-buttons))) (define (add-default-callback) (cond [(has-default?) @@ -837,12 +835,12 @@ [else (loop (- n 1))]))) (define (remove-callback) - (let ([to-delete (send collection-paths-lb get-selection)]) - (send collection-paths-lb delete to-delete) - (unless (zero? (send collection-paths-lb get-number)) - (send collection-paths-lb set-selection - (min to-delete (- (send collection-paths-lb get-number) 1)))) - (update-buttons))) + (define to-delete (send collection-paths-lb get-selection)) + (send collection-paths-lb delete to-delete) + (unless (zero? (send collection-paths-lb get-number)) + (send collection-paths-lb set-selection + (min to-delete (- (send collection-paths-lb get-number) 1)))) + (update-buttons)) (define (move-callback d) (let* ([sel (send collection-paths-lb get-selection)] @@ -856,9 +854,8 @@ (update-buttons))) (define (get-lb-vector) - (list->vector (for/list ([n (in-range (send collection-paths-lb get-number))]) - (cons (send collection-paths-lb get-string n) - (send collection-paths-lb get-data n))))) + (for/vector ([n (in-range (send collection-paths-lb get-number))]) + (cons (send collection-paths-lb get-string n) (send collection-paths-lb get-data n)))) (define (set-lb-vector vec) (send collection-paths-lb clear) diff --git a/drracket-core-lib/drracket/private/stick-figures.rkt b/drracket-core-lib/drracket/private/stick-figures.rkt index af068f910..e500542dc 100644 --- a/drracket-core-lib/drracket/private/stick-figures.rkt +++ b/drracket-core-lib/drracket/private/stick-figures.rkt @@ -154,10 +154,8 @@ (define (normalize points) (define-values (min-x min-y) (get-max/min-x/y min points)) - (map (λ (x) (list (car x) - (- (list-ref x 1) min-x) - (- (list-ref x 2) min-y))) - points)) + (for/list ([x (in-list points)]) + (list (car x) (- (list-ref x 1) min-x) (- (list-ref x 2) min-y)))) (define (get-max/min-x/y choose points) (values (apply choose @@ -185,14 +183,14 @@ (send dc set-brush "black" 'transparent) (draw-points points dc factor dx dy) - (let* ([head (assoc 'head points)] - [hx (list-ref head 1)] - [hy (list-ref head 2)]) - (send dc draw-ellipse - (+ dx (* factor (- hx (/ head-size 2)))) - (+ dy (* factor (- hy (/ head-size 2)))) - (* factor head-size) - (* factor head-size))))) + (define head (assoc 'head points)) + (define hx (list-ref head 1)) + (define hy (list-ref head 2)) + (send dc draw-ellipse + (+ dx (* factor (- hx (/ head-size 2)))) + (+ dy (* factor (- hy (/ head-size 2)))) + (* factor head-size) + (* factor head-size)))) (define (draw-points points dc factor dx dy) (connect 'neck 'shoulders points dc factor dx dy) @@ -250,13 +248,12 @@ (set! orig-y (list-ref orig-point 2)))] [(and clicked-point (send evt moving?)) (set! points - (map (λ (x) - (if (eq? (car x) clicked-point) - (list (list-ref x 0) - (+ orig-x (- (send evt get-x) clicked-x)) - (+ orig-y (- (send evt get-y) clicked-y))) - x)) - points)) + (for/list ([x (in-list points)]) + (if (eq? (car x) clicked-point) + (list (list-ref x 0) + (+ orig-x (- (send evt get-x) clicked-x)) + (+ orig-y (- (send evt get-y) clicked-y))) + x))) (refresh) (send csmall refresh)] [(send evt button-up? 'left) diff --git a/drracket-tool-text-lib/drracket/find-module-path-completions.rkt b/drracket-tool-text-lib/drracket/find-module-path-completions.rkt index c715ac956..2c4741a0d 100644 --- a/drracket-tool-text-lib/drracket/find-module-path-completions.rkt +++ b/drracket-tool-text-lib/drracket/find-module-path-completions.rkt @@ -183,20 +183,20 @@ (and (regexp? (list-ref link-ent 2)) (regexp-match (list-ref link-ent 2) (version))) #t)) - `(,(list-ref link-ent 0) - ,(simplify-path - (let* ([encoded-path (list-ref link-ent 1)] - [path (cond - [(string? encoded-path) encoded-path] - [(bytes? encoded-path) (bytes->path encoded-path)] - [else (apply build-path - (for/list ([elem (in-list encoded-path)]) - (if (bytes? elem) - (bytes->path-element elem) - elem)))])]) - (if (relative-path? path) - (build-path base path) - path)))))] + (list (list-ref link-ent 0) + (simplify-path (let* ([encoded-path (list-ref link-ent 1)] + [path (cond + [(string? encoded-path) encoded-path] + [(bytes? encoded-path) (bytes->path encoded-path)] + [else + (apply build-path + (for/list ([elem (in-list encoded-path)]) + (if (bytes? elem) + (bytes->path-element elem) + elem)))])]) + (if (relative-path? path) + (build-path base path) + path)))))] [else '()])] [else (for/list ([clp (in-list library-collection-paths)])