From 9e372da32823c1a3e30f722413eecb7f0c1b9b72 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 01/10] Fix 9 occurrences of `let-to-define` Internal definitions are recommended instead of `let` expressions, to reduce nesting. --- drracket/browser/private/bullet.rkt | 19 ++-- drracket/browser/private/html.rkt | 157 +++++++++++++--------------- 2 files changed, 81 insertions(+), 95 deletions(-) diff --git a/drracket/browser/private/bullet.rkt b/drracket/browser/private/bullet.rkt index 3ec528198..19db107e4 100644 --- a/drracket/browser/private/bullet.rkt +++ b/drracket/browser/private/bullet.rkt @@ -51,16 +51,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))] diff --git a/drracket/browser/private/html.rkt b/drracket/browser/private/html.rkt index 3514dd669..dc763a8d5 100644 --- a/drracket/browser/private/html.rkt +++ b/drracket/browser/private/html.rkt @@ -118,19 +118,17 @@ (super on-event dc x y editor-x editor-y evt)) (define/override (adjust-cursor dc x y editor-x editor-y evt) - (let ([snipx (- (send evt get-x) x)] - [snipy (- (send evt get-y) y)]) - (if (find-rect snipx snipy) - finger-cursor - #f))) + (define snipx (- (send evt get-x) x)) + (define snipy (- (send evt get-y) y)) + (if (find-rect snipx snipy) finger-cursor #f)) ;; warning: buggy. This doesn't actually copy the bitmap ;; over because there's no get-bitmap method for image-snip% ;; at the time of this writing. (define/override (copy) - (let ([cp (new image-map-snip% (html-text html-text))]) - (send cp set-key key) - (send cp set-rects rects))) + (define cp (new image-map-snip% (html-text html-text))) + (send cp set-key key) + (send cp set-rects rects)) (super-make-object) @@ -143,9 +141,9 @@ ;; (define (make-racket-color-delta col) - (let ([d (make-object style-delta%)]) - (send d set-delta-foreground col) - d)) + (define d (make-object style-delta%)) + (send d set-delta-foreground col) + d) (define racket-code-delta (make-racket-color-delta "brown")) (define racket-code-delta/keyword @@ -163,17 +161,17 @@ (define current-style-class (make-parameter null)) (define (lookup-class-delta class) - (let ([class-path (cons class (current-style-class))]) - (cond - [(sub-path? class-path '("racket")) racket-code-delta] - [(sub-path? class-path '("keyword" "racket")) racket-code-delta/keyword] - [(sub-path? class-path '("variable" "racket")) racket-code-delta/variable] - [(sub-path? class-path '("global" "racket")) racket-code-delta/global] - [(or (sub-path? class-path '("selfeval" "racket")) - (sub-path? class-path '("racketresponse"))) racket-code-delta/selfeval] - [(sub-path? class-path '("comment" "racket")) racket-code-delta/comment] - [(sub-path? class-path '("navigation")) navigation-delta] - [else #f]))) + (define class-path (cons class (current-style-class))) + (cond + [(sub-path? class-path '("racket")) racket-code-delta] + [(sub-path? class-path '("keyword" "racket")) racket-code-delta/keyword] + [(sub-path? class-path '("variable" "racket")) racket-code-delta/variable] + [(sub-path? class-path '("global" "racket")) racket-code-delta/global] + [(or (sub-path? class-path '("selfeval" "racket")) (sub-path? class-path '("racketresponse"))) + racket-code-delta/selfeval] + [(sub-path? class-path '("comment" "racket")) racket-code-delta/comment] + [(sub-path? class-path '("navigation")) navigation-delta] + [else #f])) (define (sub-path? a b) (cond @@ -241,34 +239,34 @@ ;; cache-bitmap : string -> (is-a?/c bitmap%) (define (cache-bitmap url) - (let ([url-string (url->string url)]) - (let loop ([n 0]) - (cond - [(= n NUM-CACHED) - ;; Look for item to uncache - (vector-set! cached-use 0 (max 0 (sub1 (vector-ref cached-use 0)))) - (let ([m (let loop ([n 1][m (vector-ref cached-use 0)]) - (if (= n NUM-CACHED) - m - (begin - (vector-set! cached-use n (max 0 (sub1 (vector-ref cached-use n)))) - (loop (add1 n) (min m (vector-ref cached-use n))))))]) - (let loop ([n 0]) - (if (= (vector-ref cached-use n) m) - (let ([bitmap (get-bitmap-from-url url)]) - (cond + (define url-string (url->string url)) + (let loop ([n 0]) + (cond + [(= n NUM-CACHED) + ;; Look for item to uncache + (vector-set! cached-use 0 (max 0 (sub1 (vector-ref cached-use 0)))) + (let ([m (let loop ([n 1] + [m (vector-ref cached-use 0)]) + (if (= n NUM-CACHED) + m + (begin + (vector-set! cached-use n (max 0 (sub1 (vector-ref cached-use n)))) + (loop (add1 n) (min m (vector-ref cached-use n))))))]) + (let loop ([n 0]) + (if (= (vector-ref cached-use n) m) + (let ([bitmap (get-bitmap-from-url url)]) + (cond [bitmap (vector-set! cached n bitmap) (vector-set! cached-name n url-string) (vector-set! cached-use n 5) bitmap] [else #f])) - (loop (add1 n)))))] - [(equal? url-string (vector-ref cached-name n)) - (vector-set! cached-use n (min 10 (add1 (vector-ref cached-use n)))) - (vector-ref cached n)] - [else - (loop (add1 n))])))) + (loop (add1 n)))))] + [(equal? url-string (vector-ref cached-name n)) + (vector-set! cached-use n (min 10 (add1 (vector-ref cached-use n)))) + (vector-ref cached n)] + [else (loop (add1 n))]))) (define (update-image-maps image-map-snips image-maps) (for-each @@ -305,28 +303,25 @@ ;; matches the above, it is interprted propoerly; ;; otherwise silently nothing happens. (define (add-area image-map-snip sexp) - (let ([shape #f] - [coords #f] - [href #f]) - (let loop ([sexp sexp]) - (cond - [(pair? sexp) - (let ([fst (car sexp)]) - (when (and (pair? fst) - (symbol? (car fst)) - (pair? (cdr fst)) - (string? (cadr fst))) - (case (car fst) - [(shape) (set! shape (cadr fst))] - [(coords) (set! coords (cadr fst))] - [(href) (set! href (cadr fst))] - [else (void)])) - (loop (cdr sexp)))] - [else (void)])) - (when (and shape coords href) - (let ([p-coords (parse-coords coords)]) - (when p-coords - (send image-map-snip add-area shape p-coords href)))))) + (define shape #f) + (define coords #f) + (define href #f) + (let loop ([sexp sexp]) + (cond + [(pair? sexp) + (let ([fst (car sexp)]) + (when (and (pair? fst) (symbol? (car fst)) (pair? (cdr fst)) (string? (cadr fst))) + (case (car fst) + [(shape) (set! shape (cadr fst))] + [(coords) (set! coords (cadr fst))] + [(href) (set! href (cadr fst))] + [else (void)])) + (loop (cdr sexp)))] + [else (void)])) + (when (and shape coords href) + (let ([p-coords (parse-coords coords)]) + (when p-coords + (send image-map-snip add-area shape p-coords href))))) ;; parse-coords : string -> (listof number) ;; separates out a bunch of comma separated numbers in a string @@ -337,10 +332,9 @@ [(regexp-match #rx"^[ \t\n]*([0-9]+)[ \t\n]*,(.*)$" str) => (lambda (m) - (let ([num (cadr m)] - [rst (caddr m)]) - (cons (string->number num) - (loop rst))))] + (define num (cadr m)) + (define rst (caddr m)) + (cons (string->number num) (loop rst)))] [(regexp-match #rx"^[ \t\n]*([0-9]+)[ \t\n]*" str) => (lambda (m) @@ -348,21 +342,14 @@ [else null]))) (define (make-get-field str) - (let ([s (apply - string-append - (map - (lambda (c) - (format "[~a~a]" - (char-upcase c) - (char-downcase c))) - (string->list str)))] - [spc (string #\space #\tab #\newline #\return #\vtab)]) - (let ([re:plain (regexp (format "(^|[~a])~a[~a]*=[~a]*([^~a]*)" spc s spc spc spc))] - [re:quote (regexp (format "(^|[~a])~a[~a]*=[~a]*\"([^\"]*)\"" spc s spc spc))]) - (lambda (args) - (let ([m (or (regexp-match re:quote args) - (regexp-match re:plain args))]) - (and m (caddr m))))))) + (define s + (apply string-append + (map (lambda (c) (format "[~a~a]" (char-upcase c) (char-downcase c))) (string->list str)))) + (define spc (string #\space #\tab #\newline #\return #\vtab)) + (define re:plain (regexp (format "(^|[~a])~a[~a]*=[~a]*([^~a]*)" spc s spc spc spc))) + (define re:quote (regexp (format "(^|[~a])~a[~a]*=[~a]*\"([^\"]*)\"" spc s spc spc))) + (lambda (args) + (let ([m (or (regexp-match re:quote args) (regexp-match re:plain args))]) (and m (caddr m))))) (define (get-field e name) (let ([a (assq name (cadr e))]) From 21a195c2211ac12389493a2088a489756062adb5 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 02/10] Fix 1 occurrence of `define-lambda-to-define` The `define` form supports a shorthand for defining functions. --- drracket/browser/private/html.rkt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drracket/browser/private/html.rkt b/drracket/browser/private/html.rkt index dc763a8d5..d99a45c74 100644 --- a/drracket/browser/private/html.rkt +++ b/drracket/browser/private/html.rkt @@ -191,15 +191,14 @@ (define re:hexcolor (regexp "^#([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$")) -(define color-string->color - (lambda (str) - (let ([m (regexp-match re:hexcolor str)]) - (if m - (make-object color% - (string->number (cadr m) 16) - (string->number (caddr m) 16) - (string->number (cadddr m) 16)) - (send the-color-database find-color str))))) +(define (color-string->color str) + (let ([m (regexp-match re:hexcolor str)]) + (if m + (make-object color% + (string->number (cadr m) 16) + (string->number (caddr m) 16) + (string->number (cadddr m) 16)) + (send the-color-database find-color str)))) (define html-eval-ok (make-parameter #t)) (define html-img-ok (make-parameter #t)) From 24e5a54b68f0fe5aaa6f905ffbe55fbca8d87dcb Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 03/10] Fix 1 occurrence of `if-else-false-to-and` This `if` expression can be refactored to an equivalent expression using `and`. --- drracket/browser/private/html.rkt | 53 +++++++++++++------------------ 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/drracket/browser/private/html.rkt b/drracket/browser/private/html.rkt index d99a45c74..3d931a30e 100644 --- a/drracket/browser/private/html.rkt +++ b/drracket/browser/private/html.rkt @@ -204,37 +204,28 @@ (define html-img-ok (make-parameter #t)) (define (get-bitmap-from-url url) - (if (html-img-ok) - (let ([tmp-filename (make-temporary-file "rktguiimg~a")]) - (load-status #t "image" url) - (call-with-output-file* tmp-filename - (lambda (op) - (with-handlers ([exn:fail? - (lambda (x) - (printf "exn.9 ~s\n" (and (exn? x) - (exn-message x))) - (void))]) - (call/input-url - url - get-pure-port - (lambda (ip) - (copy-port ip op))))) - #:exists 'truncate) - (pop-status) - (let ([bitmap (make-object bitmap% tmp-filename)]) - (with-handlers ([exn:fail? - (lambda (x) - (message-box "Warning" - (format "Could not delete file ~s\n\n~a" - tmp-filename - (if (exn? x) - (exn-message x) - x))))]) - (delete-file tmp-filename)) - (if (send bitmap ok?) - bitmap - #f))) - #f)) + (and (html-img-ok) + (let ([tmp-filename (make-temporary-file "rktguiimg~a")]) + (load-status #t "image" url) + (call-with-output-file* + tmp-filename + (lambda (op) + (with-handlers ([exn:fail? (lambda (x) + (printf "exn.9 ~s\n" (and (exn? x) (exn-message x))) + (void))]) + (call/input-url url get-pure-port (lambda (ip) (copy-port ip op))))) + #:exists 'truncate) + (pop-status) + (let ([bitmap (make-object bitmap% tmp-filename)]) + (with-handlers ([exn:fail? (lambda (x) + (message-box "Warning" + (format "Could not delete file ~s\n\n~a" + tmp-filename + (if (exn? x) + (exn-message x) + x))))]) + (delete-file tmp-filename)) + (if (send bitmap ok?) bitmap #f))))) ;; cache-bitmap : string -> (is-a?/c bitmap%) (define (cache-bitmap url) From 27f4decf1c7a901d2c79624e2043d6ded622b2fa Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 04/10] Fix 2 occurrences of `for-each-to-for` This `for-each` operation can be replaced with a `for` loop. --- drracket/browser/private/html.rkt | 26 ++++++++++-------------- drracket/browser/private/option-snip.rkt | 19 ++++++++--------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/drracket/browser/private/html.rkt b/drracket/browser/private/html.rkt index 3d931a30e..e482f3b6f 100644 --- a/drracket/browser/private/html.rkt +++ b/drracket/browser/private/html.rkt @@ -259,21 +259,17 @@ [else (loop (add1 n))]))) (define (update-image-maps image-map-snips image-maps) - (for-each - (lambda (image-map-snip) - (let ([image-map-key (send image-map-snip get-key)]) - (let loop ([image-maps image-maps]) - (cond - [(null? image-maps) (void)] - [else - (let* ([image-map (car image-maps)] - [name (get-field image-map 'name)]) - (if (and name - (equal? (format "#~a" name) - (send image-map-snip get-key))) - (find/add-areas image-map-snip image-map) - (loop (cdr image-maps))))])))) - image-map-snips)) + (for ([image-map-snip (in-list image-map-snips)]) + (send image-map-snip get-key) + (let loop ([image-maps image-maps]) + (cond + [(null? image-maps) (void)] + [else + (let* ([image-map (car image-maps)] + [name (get-field image-map 'name)]) + (if (and name (equal? (format "#~a" name) (send image-map-snip get-key))) + (find/add-areas image-map-snip image-map) + (loop (cdr image-maps))))])))) (define (find/add-areas image-map-snip image-map) (let loop ([sexp image-map]) diff --git a/drracket/browser/private/option-snip.rkt b/drracket/browser/private/option-snip.rkt index 4d3610dd1..a7229339b 100644 --- a/drracket/browser/private/option-snip.rkt +++ b/drracket/browser/private/option-snip.rkt @@ -101,16 +101,15 @@ [on-event (lambda (dc x y editorx editory event) (when (send event button-down?) (define popup (make-object popup-menu%)) - (for-each (lambda (o) - (make-object menu-item% - (car o) - popup - (lambda (i e) - (set! current-option o) - (let ([a (get-admin)]) - (when a - (send a needs-update this 0 0 w h)))))) - options) + (for ([o (in-list options)]) + (make-object menu-item% + (car o) + popup + (lambda (i e) + (set! current-option o) + (let ([a (get-admin)]) + (when a + (send a needs-update this 0 0 w h)))))) (define a (get-admin)) (when a (send a popup-menu popup this 0 0))))] From 3d781cd068f8b1fbf2151f31f49acaf7bdc10769 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 05/10] Fix 1 occurrence of `apply-flattening` The `apply` function accepts single arguments in addition to a trailing list argument. --- .../drracket/private/standalone-module-browser.rkt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drracket-tool-lib/drracket/private/standalone-module-browser.rkt b/drracket-tool-lib/drracket/private/standalone-module-browser.rkt index 807be068e..fdc4494fb 100644 --- a/drracket-tool-lib/drracket/private/standalone-module-browser.rkt +++ b/drracket-tool-lib/drracket/private/standalone-module-browser.rkt @@ -1272,7 +1272,8 @@ [(null? ms) (substring short-name 0 (min 2 (string-length short-name)))] [else (apply string-append - (cons (substring short-name 0 1) (map (λ (x) (substring x 1 2)) ms)))])])] + (substring short-name 0 1) + (map (λ (x) (substring x 1 2)) ms))])])] [(long) word] [(very-long) (string-append word ": " (format "~s" require-phases))])) last-name])) From 9646d2294f9e73073803f1e1a4eaec2d39a7aed8 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 06/10] Fix 1 occurrence of `when-expression-in-for-loop-to-when-keyword` Use the `#:when` keyword instead of `when` to reduce loop body indentation. --- drracket/gui-debugger/debug-tool.rkt | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drracket/gui-debugger/debug-tool.rkt b/drracket/gui-debugger/debug-tool.rkt index 722ddee82..d6fcebb56 100644 --- a/drracket/gui-debugger/debug-tool.rkt +++ b/drracket/gui-debugger/debug-tool.rkt @@ -486,26 +486,26 @@ (when (and (send (get-tab) debug?) (not before)) ;; render breakpoints (let ([breakpoints (send (get-tab) get-breakpoints)]) - (for ([(pos enabled?) (in-hash breakpoints)]) - (when (and (>= pos 0) (or enabled? (and mouse-over-pos (= mouse-over-pos pos)))) - (define-values (xl yl xr yr) (find-char-box this pos)) - (define diameter (- xr xl)) - (define yoff (/ (- yr yl diameter) 2)) - (define op (send dc get-pen)) - (define ob (send dc get-brush)) - (case enabled? - [(#t) - (send dc set-pen bp-pen) - (send dc set-brush bp-brush)] - [(#f) - (send dc set-pen bp-mo-pen) - (send dc set-brush bp-mo-brush)] - [else - (send dc set-pen bp-tmp-pen) - (send dc set-brush bp-tmp-brush)]) - (send dc draw-ellipse (+ xl dx) (+ yl dy yoff) diameter diameter) - (send dc set-pen op) - (send dc set-brush ob)))) + (for ([(pos enabled?) (in-hash breakpoints)] + #:when (and (>= pos 0) (or enabled? (and mouse-over-pos (= mouse-over-pos pos))))) + (define-values (xl yl xr yr) (find-char-box this pos)) + (define diameter (- xr xl)) + (define yoff (/ (- yr yl diameter) 2)) + (define op (send dc get-pen)) + (define ob (send dc get-brush)) + (case enabled? + [(#t) + (send dc set-pen bp-pen) + (send dc set-brush bp-brush)] + [(#f) + (send dc set-pen bp-mo-pen) + (send dc set-brush bp-mo-brush)] + [else + (send dc set-pen bp-tmp-pen) + (send dc set-brush bp-tmp-brush)]) + (send dc draw-ellipse (+ xl dx) (+ yl dy yoff) diameter diameter) + (send dc set-pen op) + (send dc set-brush ob))) ;; mark the boundaries of the current stack frame ;; unless we're at the end of the expression and looking at the top frame, ;; in which case just mark the current location From b9963dc2258500fbb2a1bbac78100c11878bd936 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 07/10] Fix 2 occurrences of `map-to-for` This `map` operation can be replaced with a `for/list` loop. --- drracket/browser/private/option-snip.rkt | 7 +++--- drracket/gui-debugger/debug-tool.rkt | 29 ++++++++++++------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/drracket/browser/private/option-snip.rkt b/drracket/browser/private/option-snip.rkt index a7229339b..6469c0501 100644 --- a/drracket/browser/private/option-snip.rkt +++ b/drracket/browser/private/option-snip.rkt @@ -52,10 +52,9 @@ (unless w (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)) + (for/list ([o (in-list options)]) + (define-values (tw th td ta) (send dc get-text-extent (car o) font)) + (list tw th td))) (if (null? w+h+ds) (begin (set! w 10) diff --git a/drracket/gui-debugger/debug-tool.rkt b/drracket/gui-debugger/debug-tool.rkt index d6fcebb56..7a5f94f7d 100644 --- a/drracket/gui-debugger/debug-tool.rkt +++ b/drracket/gui-debugger/debug-tool.rkt @@ -1234,21 +1234,20 @@ (define/public (register-stack-frames frames already-stopped?) (define trimmed-exprs - (map (lambda (frame) - (let ([expr (mark-source frame)]) - (cond - ; should succeed unless the user closes a secondary tab during debugging - [(and expr (filename->defs (syntax-source expr))) - => - (lambda (defs) - (trim-expr-str (if (syntax-position expr) - (send defs get-text - (sub1 (syntax-position expr)) - (+ -1 (syntax-position expr) (syntax-span expr))) - "??") - 15))] - ["??"]))) - frames)) + (for/list ([frame (in-list frames)]) + (define expr (mark-source frame)) + (cond + ; should succeed unless the user closes a secondary tab during debugging + [(and expr (filename->defs (syntax-source expr))) + => + (lambda (defs) + (trim-expr-str (if (syntax-position expr) + (send defs get-text + (sub1 (syntax-position expr)) + (+ -1 (syntax-position expr) (syntax-span expr))) + "??") + 15))] + ["??"]))) (send stack-frames begin-edit-sequence) (send stack-frames lock #f) (unless already-stopped? From 7536896db280eb3a3b9d96b063177f7ff5159d77 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 08/10] Fix 1 occurrence of `if-begin-to-cond` Using `cond` instead of `if` here makes `begin` unnecessary --- drracket/browser/private/option-snip.rkt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drracket/browser/private/option-snip.rkt b/drracket/browser/private/option-snip.rkt index 6469c0501..caaba6064 100644 --- a/drracket/browser/private/option-snip.rkt +++ b/drracket/browser/private/option-snip.rkt @@ -55,15 +55,15 @@ (for/list ([o (in-list options)]) (define-values (tw th td ta) (send dc get-text-extent (car o) font)) (list tw th td))) - (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))))))) + (cond + [(null? w+h+ds) + (set! w 10) + (set! h 10) + (set! d 2)] + [else + (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 From 3062d0d2f6fa9557e9229e9ad66213ef2ea2c97c Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 09/10] Fix 1 occurrence of `send-chain-to-send+` This method chain made of nested `send` expressions can be written more clearly as a `send+` expression. --- drracket/browser/private/bullet.rkt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drracket/browser/private/bullet.rkt b/drracket/browser/private/bullet.rkt index 19db107e4..65b587544 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) From 2f1136a38014d6a4bf70fab0a25ce142cf2b029c Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 13 Jul 2025 00:13:35 +0000 Subject: [PATCH 10/10] Fix 1 occurrence of `nested-if-to-cond` This `if`-`else` chain can be converted to a `cond` expression. --- drracket/browser/private/bullet.rkt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drracket/browser/private/bullet.rkt b/drracket/browser/private/bullet.rkt index 65b587544..554bdaa9d 100644 --- a/drracket/browser/private/bullet.rkt +++ b/drracket/browser/private/bullet.rkt @@ -67,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)))