diff --git a/drracket/browser/private/bullet.rkt b/drracket/browser/private/bullet.rkt index 3ec528198..10703d7f3 100644 --- a/drracket/browser/private/bullet.rkt +++ b/drracket/browser/private/bullet.rkt @@ -11,8 +11,7 @@ (define bullet-size (make-parameter - (let ([s (send (send (send (make-object text%) get-style-list) basic-style) - get-size)]) + (let ([s (send+ (make-object text%) (get-style-list) (basic-style) (get-size))]) (max 7 (quotient s 2))))) (define (get-bullet-width) @@ -51,16 +50,15 @@ [(0) (values (lambda (x y w h) (send dc draw-ellipse x y w h)) #t)] [(1) (values (lambda (x y w h) (send dc draw-ellipse x y w h)) #f)] [else (values (lambda (x y w h) (send dc draw-rectangle x y w h)) #f)])]) - (let ([b (send dc get-brush)]) - (send dc set-brush - (if solid? - (send the-brush-list - find-or-create-brush - (send (send dc get-pen) get-color) - 'solid) - transparent-brush)) - (draw x y bsize bsize) - (send dc set-brush b)))))] + (define b (send dc get-brush)) + (send + dc + set-brush + (if solid? + (send the-brush-list find-or-create-brush (send (send dc get-pen) get-color) 'solid) + transparent-brush)) + (draw x y bsize bsize) + (send dc set-brush b))))] [define/override copy (lambda () (make-object bullet-snip% depth))] @@ -69,11 +67,10 @@ (send stream put depth))] [define/override get-text (lambda (offset num flattened?) - (if (< num 1) - "" - (if flattened? - "* " - "*")))] + (cond + [(< num 1) ""] + [flattened? "* "] + [else "*"]))] (super-new) (set-snipclass bullet-snip-class) (set-count 1))) diff --git a/drracket/browser/private/entity-names.rkt b/drracket/browser/private/entity-names.rkt index 0095cff99..9809e7099 100644 --- a/drracket/browser/private/entity-names.rkt +++ b/drracket/browser/private/entity-names.rkt @@ -256,6 +256,6 @@ (euro . 8364))) (define (entity-name->integer s) - (hash-ref table s (lambda () #f))) + (hash-ref table s #f)) diff --git a/drracket/browser/private/option-snip.rkt b/drracket/browser/private/option-snip.rkt index c857ae12e..5cc21143b 100644 --- a/drracket/browser/private/option-snip.rkt +++ b/drracket/browser/private/option-snip.rkt @@ -31,9 +31,9 @@ (set! current-option (cons o v))) (set! w #f) (set! h #f) - (let ([a (get-admin)]) - (when a - (send a resized this #t)))) + (define a (get-admin)) + (when a + (send a resized this #t))) (define/public (get-value) (with-handlers ([exn:fail? (lambda (x) #f)]) @@ -41,30 +41,30 @@ (car options))))) (define/public (set-value v) - (let ([o (ormap (lambda (o) (and (equal? v (cdr o)) o)) options)]) - (if o - (set! current-option o) - (set! look-for-option (box v))))) + (define o (ormap (lambda (o) (and (equal? v (cdr o)) o)) options)) + (if o + (set! current-option o) + (set! look-for-option (box v)))) (override* [get-extent ; called by an editor to get the snip's size (lambda (dc x y wbox hbox descentbox spacebox lspacebox rspacebox) (unless w - (let ([font (send (get-style) get-font)]) - (let ([w+h+ds - (map (lambda (o) - (let-values ([(tw th td ta) (send dc get-text-extent (car o) font)]) - (list tw th td))) - options)]) - (if (null? w+h+ds) - (begin - (set! w 10) - (set! h 10) - (set! d 2)) - (begin - (set! w (+ (* 2 inset) arrow-sep 2 (* 2 arrow-height) (apply max (map car w+h+ds)))) - (set! h (+ (* 2 inset) 1 (apply max arrow-height (map cadr w+h+ds)))) - (set! d (+ inset 1 (apply max (map caddr w+h+ds))))))))) + (define font (send (get-style) get-font)) + (define w+h+ds + (map (lambda (o) + (let-values ([(tw th td ta) (send dc get-text-extent (car o) font)]) + (list tw th td))) + options)) + (if (null? w+h+ds) + (begin + (set! w 10) + (set! h 10) + (set! d 2)) + (begin + (set! w (+ (* 2 inset) arrow-sep 2 (* 2 arrow-height) (apply max (map car w+h+ds)))) + (set! h (+ (* 2 inset) 1 (apply max arrow-height (map cadr w+h+ds)))) + (set! d (+ inset 1 (apply max (map caddr w+h+ds))))))) (when hbox (set-box! hbox h)) (when wbox diff --git a/drracket/drracket/drracket.rkt b/drracket/drracket/drracket.rkt index bb2c621c4..6f3647f00 100644 --- a/drracket/drracket/drracket.rkt +++ b/drracket/drracket/drracket.rkt @@ -24,17 +24,15 @@ (flush-output)) (define (run-trace-thread) - (let ([evt (make-log-receiver (current-logger) 'info)]) - (void - (thread - (λ () - (let loop () - (define vec (sync evt)) - (define str (vector-ref vec 1)) - (when (regexp-match #rx"^cm: *compil(ing|ed)" str) - (display str) - (newline)) - (loop))))))) + (define evt (make-log-receiver (current-logger) 'info)) + (void (thread (λ () + (let loop () + (define vec (sync evt)) + (define str (vector-ref vec 1)) + (when (regexp-match #rx"^cm: *compil(ing|ed)" str) + (display str) + (newline)) + (loop)))))) (cond [debugging? @@ -57,14 +55,14 @@ (run-trace-thread)))] [install-cm? (flprintf "PLTDRCM: loading compilation manager\n") - (let ([make-compilation-manager-load/use-compiled-handler - (parameterize ([current-namespace (make-base-empty-namespace)]) - (dynamic-require 'compiler/cm 'make-compilation-manager-load/use-compiled-handler))]) - (flprintf "PLTDRCM: installing compilation manager\n") - (current-load/use-compiled (make-compilation-manager-load/use-compiled-handler)) - (when cm-trace? - (flprintf "PLTDRCM: enabling CM tracing\n") - (run-trace-thread)))] + (define make-compilation-manager-load/use-compiled-handler + (parameterize ([current-namespace (make-base-empty-namespace)]) + (dynamic-require 'compiler/cm 'make-compilation-manager-load/use-compiled-handler))) + (flprintf "PLTDRCM: installing compilation manager\n") + (current-load/use-compiled (make-compilation-manager-load/use-compiled-handler)) + (when cm-trace? + (flprintf "PLTDRCM: enabling CM tracing\n") + (run-trace-thread))] [first-parallel? (flprintf "PLTDRPAR: loading compilation manager\n") (define tools? (not (getenv "PLTNOTOOLS"))) @@ -90,19 +88,17 @@ (define (tool-files id) (apply append - (map - (λ (x) - (define proc (get-info/full x)) - (if proc - (map (λ (dirs) - (apply build-path - x - (if (list? dirs) - dirs - (list dirs)))) - (proc id (λ () '()))) - '())) - (find-relevant-directories (list id))))) + (for/list ([x (in-list (find-relevant-directories (list id)))]) + (define proc (get-info/full x)) + (if proc + (map (λ (dirs) + (apply build-path + x + (if (list? dirs) + dirs + (list dirs)))) + (proc id (λ () '()))) + '())))) (define make-compilation-manager-load/use-compiled-handler (parameterize ([current-namespace (make-base-empty-namespace)]) @@ -146,11 +142,11 @@ ;; it creates a new custodian and installs it, but the ;; original eventspace was created on the original custodian ;; and this code does not create a new eventspace. - (let ([orig-cust (current-custodian)] - [orig-eventspace (current-eventspace)] - [new-cust (make-custodian)]) - (current-custodian new-cust) - ((dynamic-require 'drracket/private/profile-drs 'start-profile) orig-cust))) + (define orig-cust (current-custodian)) + (current-eventspace) + (define new-cust (make-custodian)) + (current-custodian new-cust) + ((dynamic-require 'drracket/private/profile-drs 'start-profile) orig-cust)) (dynamic-require 'drracket/private/drracket-normal #f) diff --git a/drracket/drracket/sprof.rkt b/drracket/drracket/sprof.rkt index 0f5062686..6d2ca2f26 100644 --- a/drracket/drracket/sprof.rkt +++ b/drracket/drracket/sprof.rkt @@ -14,44 +14,40 @@ (define traces-table (make-hash)) (let loop ([i 0]) (sleep pause-time) - (let ([new-traces - (map (λ (t) (continuation-mark-set->context (continuation-marks t))) - (get-threads))]) - (for-each - (λ (trace) - (for-each - (λ (line) - (hash-set! traces-table line (cons trace (hash-ref traces-table line '())))) - trace)) - new-traces) - (cond - [(zero? i) - (update-gui traces-table) - (loop update-frequency)] - [else - (loop (- i 1))])))))) + (define new-traces + (map (λ (t) (continuation-mark-set->context (continuation-marks t))) (get-threads))) + (for-each (λ (trace) + (for-each (λ (line) + (hash-set! traces-table + line + (cons trace (hash-ref traces-table line '())))) + trace)) + new-traces) + (cond + [(zero? i) + (update-gui traces-table) + (loop update-frequency)] + [else (loop (- i 1))]))))) (define (format-fn-name i) - (let ([id (car i)] - [src (cdr i)]) - (cond - [id (format "~a" id)] - [src - (format "~a:~a~a" - (cond - [(path? (srcloc-source src)) - (let-values ([(base name dir?) (split-path (srcloc-source src))]) - name)] - [else (srcloc-source src)]) - (if (srcloc-line src) - (format "~a:~a" - (srcloc-line src) - (srcloc-column src)) - (srcloc-position src)) - (if id - (format ": ~a" id) - ""))] - [else "???"]))) + (define id (car i)) + (define src (cdr i)) + (cond + [id (format "~a" id)] + [src + (format "~a:~a~a" + (cond + [(path? (srcloc-source src)) + (let-values ([(base name dir?) (split-path (srcloc-source src))]) + name)] + [else (srcloc-source src)]) + (if (srcloc-line src) + (format "~a:~a" (srcloc-line src) (srcloc-column src)) + (srcloc-position src)) + (if id + (format ": ~a" id) + ""))] + [else "???"])) (define (insert-long-fn-name t i) (send t begin-edit-sequence) @@ -76,8 +72,8 @@ (send t end-edit-sequence)) (define (format-percentage n) - (let ([trunc (floor (* n 100))]) - (format "~a%" (pad3 trunc)))) + (define trunc (floor (* n 100))) + (format "~a%" (pad3 trunc))) (define (pad3 n) (cond @@ -110,16 +106,16 @@ (define/override (on-event event) (cond [(send event button-up? 'left) - (let ([admin (get-admin)]) - (when admin - (let ([dc (send admin get-dc)]) - (let-values ([(x y) (dc-location-to-editor-location (send event get-x) - (send event get-y))]) - (let* ([loc (find-position x y)] - [para (position-paragraph loc)]) - (set! clicked-srcloc-pr (and (<= 0 para (last-paragraph)) - (car (list-ref gui-display-data para)))) - (update-gui-display))))))] + (define admin (get-admin)) + (when admin + (let ([dc (send admin get-dc)]) + (let-values ([(x y) (dc-location-to-editor-location (send event get-x) + (send event get-y))]) + (let* ([loc (find-position x y)] + [para (position-paragraph loc)]) + (set! clicked-srcloc-pr + (and (<= 0 para (last-paragraph)) (car (list-ref gui-display-data para)))) + (update-gui-display)))))] [else (void)])) (define/public (set-gui-display-data/refresh traces-table) @@ -140,42 +136,43 @@ (set! line-to-source (make-hasheq)) (clear-old-pr) (set! clear-old-pr void) - (let* ([denom-ht (make-hasheq)] - [filtered-gui-display-data - (map - (λ (pr) - (let ([id (car pr)] - [stacks (filter-stacks (cdr pr))]) - (for-each (λ (stack) (hash-set! denom-ht stack #t)) stacks) - (cons id stacks))) - gui-display-data)] - [denom-count (hash-count denom-ht)]) - (let loop ([prs filtered-gui-display-data] - [first? #t] - [i 0]) - (cond - [(null? prs) (void)] - [else - (let* ([pr (car prs)] - [fn (car pr)] - [count (length (cdr pr))]) - (cond - [(zero? count) - (loop (cdr prs) first? i)] - [else - (unless first? (insert "\n")) - (let ([before (last-position)]) - (hash-set! line-to-source i pr) - (insert (format-percentage (/ count denom-count))) - (insert (format " ~a" (format-fn-name fn))) - (let ([after (last-position)]) - (when (equal? (car pr) clicked-srcloc-pr) - (set! clear-old-pr (highlight-range before after "NavajoWhite"))))) - (loop (cdr prs) #f (+ i 1))]))])) - (lock #t) - (end-edit-sequence) - (update-info-editor clicked-srcloc-pr) - (send open-button enable (and clicked-srcloc-pr (path? (srcloc-source (cdr clicked-srcloc-pr))))))) + (define denom-ht (make-hasheq)) + (define filtered-gui-display-data + (map (λ (pr) + (let ([id (car pr)] + [stacks (filter-stacks (cdr pr))]) + (for-each (λ (stack) (hash-set! denom-ht stack #t)) stacks) + (cons id stacks))) + gui-display-data)) + (define denom-count (hash-count denom-ht)) + (let loop ([prs filtered-gui-display-data] + [first? #t] + [i 0]) + (cond + [(null? prs) (void)] + [else + (let* ([pr (car prs)] + [fn (car pr)] + [count (length (cdr pr))]) + (cond + [(zero? count) (loop (cdr prs) first? i)] + [else + (unless first? + (insert "\n")) + (let ([before (last-position)]) + (hash-set! line-to-source i pr) + (insert (format-percentage (/ count denom-count))) + (insert (format " ~a" (format-fn-name fn))) + (let ([after (last-position)]) + (when (equal? (car pr) clicked-srcloc-pr) + (set! clear-old-pr (highlight-range before after "NavajoWhite"))))) + (loop (cdr prs) #f (+ i 1))]))])) + (lock #t) + (end-edit-sequence) + (update-info-editor clicked-srcloc-pr) + (send open-button + enable + (and clicked-srcloc-pr (path? (srcloc-source (cdr clicked-srcloc-pr)))))) (define/private (filter-stacks stacks) (cond @@ -187,11 +184,11 @@ (define/public (open-current-pr) (when clicked-srcloc-pr - (let ([src (cdr clicked-srcloc-pr)]) - (when (path? (srcloc-source src)) - (printf "open ~s\n" (srcloc-source src)) - (when (number? (srcloc-position src)) - (printf "go to ~s\n" (srcloc-position src))))))) + (define src (cdr clicked-srcloc-pr)) + (when (path? (srcloc-source src)) + (printf "open ~s\n" (srcloc-source src)) + (when (number? (srcloc-position src)) + (printf "go to ~s\n" (srcloc-position src)))))) (define/private (update-info-editor pr) (send vp change-children (λ (l) (if pr (list ec1 lp) (list ec1)))) @@ -295,17 +292,16 @@ (define show/hide-menu-item #f) (define/public (show/hide-sprof-panel show?) - (let ([main-children (send main-panel get-children)]) - (send show/hide-menu-item - set-label - (if show? sc-hide-sprof sc-show-sprof)) - (unless (or (and show? (= 2 (length main-children))) - (and (not show?) (= 1 (length main-children)))) - (send main-panel change-children - (λ (l) - (if show? - (list everything-else sprof-main-panel) - (list everything-else))))))) + (define main-children (send main-panel get-children)) + (send show/hide-menu-item set-label (if show? sc-hide-sprof sc-show-sprof)) + (unless (or (and show? (= 2 (length main-children))) + (and (not show?) (= 1 (length main-children)))) + (send main-panel + change-children + (λ (l) + (if show? + (list everything-else sprof-main-panel) + (list everything-else)))))) (define/override (make-root-area-container cls parent) (set! main-panel (super make-root-area-container panel:horizontal-dragable% parent)) @@ -377,15 +373,14 @@ (mixin (drscheme:rep:text<%>) () (inherit get-user-custodian) (define/public (get-threads-to-profile) - (let ([thds '()]) - (let loop ([cust (get-user-custodian)]) - (for-each - (λ (obj) - (cond - [(custodian? obj) (loop obj)] - [(thread? obj) (set! thds (cons obj thds))])) - (custodian-managed-list cust system-custodian))) - thds)) + (define thds '()) + (let loop ([cust (get-user-custodian)]) + (for-each (λ (obj) + (cond + [(custodian? obj) (loop obj)] + [(thread? obj) (set! thds (cons obj thds))])) + (custodian-managed-list cust system-custodian))) + thds) ;; FIX ;; something needs to happen here so that the profiling gets shutdown when the repl dies. diff --git a/drracket/setup/plt-installer-unit.rkt b/drracket/setup/plt-installer-unit.rkt index a31eee5f8..aba9b2ca9 100644 --- a/drracket/setup/plt-installer-unit.rkt +++ b/drracket/setup/plt-installer-unit.rkt @@ -41,12 +41,10 @@ (sleep 0.2) ; kludge to allow f to appear first (end-busy-cursor) ;; do these strings ever appear? (should move to string-constants, if so) - (let ([d (get-directory - "Select the destination for unpacking" - frame)]) - (unless d - (printf ">>> Cancelled <<<\n")) - (begin-busy-cursor) - d)) + (define d (get-directory "Select the destination for unpacking" frame)) + (unless d + (printf ">>> Cancelled <<<\n")) + (begin-busy-cursor) + d) #:show-beginning-of-file? #t)) cleanup-thunk)))