From 5cd9fbd95c83c882021c8f7f092c8e04216c5821 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:11:57 +0000 Subject: [PATCH 1/6] Fix 14 occurrences of `let-to-define` Internal definitions are recommended instead of `let` expressions, to reduce nesting. --- .../private/standalone-module-browser.rkt | 102 +++--- drracket/gui-debugger/debug-tool.rkt | 312 +++++++++--------- 2 files changed, 208 insertions(+), 206 deletions(-) diff --git a/drracket-tool-lib/drracket/private/standalone-module-browser.rkt b/drracket-tool-lib/drracket/private/standalone-module-browser.rkt index 31ca6ecd4..84651147a 100644 --- a/drracket-tool-lib/drracket/private/standalone-module-browser.rkt +++ b/drracket-tool-lib/drracket/private/standalone-module-browser.rkt @@ -412,13 +412,13 @@ ;; note: the preference drracket:module-browser:name-length is also used for ;; the View|Show Module Browser version of the module browser ;; here we just treat any pref value except '3' as if it were for the long names. - (let ([selection (send module-browser-name-length-choice get-selection)]) - (preferences:set 'drracket:module-browser:name-length (+ 2 selection)) - (send pasteboard - set-name-length - (case selection - [(0) 'long] - [(1) 'very-long]))))))) + (define selection (send module-browser-name-length-choice get-selection)) + (preferences:set 'drracket:module-browser:name-length (+ 2 selection)) + (send pasteboard + set-name-length + (case selection + [(0) 'long] + [(1) 'very-long])))))) (send pkg-choice set-string-selection (send pasteboard get-main-file-pkg)) (define ec (make-object overview-editor-canvas% vp pasteboard)) @@ -1059,24 +1059,25 @@ (let loop ([snips this-level-snips] [minor-dim (/ (- max-minor this-minor) 2)]) (unless (null? snips) - (let* ([snip (car snips)] - [new-major-coord (+ major-dim - (floor (- (/ this-major 2) - (/ (if vertical? - (get-snip-height snip) - (get-snip-width snip)) - 2))))]) - (if vertical? - (move-to snip minor-dim new-major-coord) - (move-to snip new-major-coord minor-dim)) - (loop (cdr snips) - (+ minor-dim - (if vertical? - (get-snip-hspace) - (get-snip-vspace)) - (if vertical? - (get-snip-width snip) - (get-snip-height snip))))))) + (define snip (car snips)) + (define new-major-coord + (+ major-dim + (floor (- (/ this-major 2) + (/ (if vertical? + (get-snip-height snip) + (get-snip-width snip)) + 2))))) + (if vertical? + (move-to snip minor-dim new-major-coord) + (move-to snip new-major-coord minor-dim)) + (loop (cdr snips) + (+ minor-dim + (if vertical? + (get-snip-hspace) + (get-snip-vspace)) + (if vertical? + (get-snip-width snip) + (get-snip-height snip)))))) (loop (cdr levels) (+ major-dim (if vertical? @@ -1119,8 +1120,8 @@ (let loop ([snip (find-first-snip)]) (when snip (when (is-a? snip boxed-word-snip<%>) - (let ([filename (send snip get-filename)]) - (on-boxed-word-double-click filename))) + (define filename (send snip get-filename)) + (on-boxed-word-double-click filename)) (loop (send snip next)))))]) (send canvas popup-menu right-button-menu (+ (send evt get-x) 1) (+ (send evt get-y) 1))] [else (super on-event evt)])) @@ -1256,19 +1257,20 @@ "" (string (string-ref word 0)))] [(medium) - (let ([m (regexp-match #rx"^(.*)\\.[^.]*$" word)]) - (let ([short-name (if m - (cadr m) - word)]) - (if (string=? short-name "") - "" - (let ([ms (regexp-match* #rx"-[^-]*" short-name)]) - (cond - [(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)))])))))] + (define m (regexp-match #rx"^(.*)\\.[^.]*$" word)) + (define short-name + (if m + (cadr m) + word)) + (if (string=? short-name "") + "" + (let ([ms (regexp-match* #rx"-[^-]*" short-name)]) + (cond + [(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)))])))] [(long) word] [(very-long) (string-append word ": " (format "~s" require-phases))])) last-name])) @@ -1345,16 +1347,16 @@ (λ () (moddep-current-open-input-file (λ (filename) - (let* ([p (open-input-file filename)] - [wxme? (regexp-match-peek #rx#"^WXME" p)]) - (if wxme? - (let ([t (new text%)]) - (close-input-port p) - (send t load-file filename) - (let ([prt (open-input-text-editor t)]) - (port-count-lines! prt) - prt)) - p)))) + (define p (open-input-file filename)) + (define wxme? (regexp-match-peek #rx#"^WXME" p)) + (if wxme? + (let ([t (new text%)]) + (close-input-port p) + (send t load-file filename) + (let ([prt (open-input-text-editor t)]) + (port-count-lines! prt) + prt)) + p))) (current-load-relative-directory #f) (define relative? (eq? init-dir 'relative)) (unless relative? ; already there diff --git a/drracket/gui-debugger/debug-tool.rkt b/drracket/gui-debugger/debug-tool.rkt index 397e6fe5c..72d5b921d 100644 --- a/drracket/gui-debugger/debug-tool.rkt +++ b/drracket/gui-debugger/debug-tool.rkt @@ -111,16 +111,14 @@ ;; (
) => () ;; ( ... ) => ( ...) (define (trim-expr-str str [len 10]) - (let* ([strlen (string-length str)] - [starts-with-paren (and (> strlen 0) (char=? (string-ref str 0) #\())] - [len2 (+ len 4)] - [trunc-pos (safe-min (index-of #\space str) - (index-of #\newline str) - (and (> strlen len2) len) - strlen)]) - (if (>= trunc-pos strlen) - str - (string-append (substring str 0 trunc-pos) (if starts-with-paren " ...)" " ..."))))) + (define strlen (string-length str)) + (define starts-with-paren (and (> strlen 0) (char=? (string-ref str 0) #\())) + (define len2 (+ len 4)) + (define trunc-pos + (safe-min (index-of #\space str) (index-of #\newline str) (and (> strlen len2) len) strlen)) + (if (>= trunc-pos strlen) + str + (string-append (substring str 0 trunc-pos) (if starts-with-paren " ...)" " ...")))) (define (average . values) (/ (apply + values) (length values))) @@ -261,23 +259,23 @@ (define event-y (send event get-y)) (define on-it? (box #f)) (let loop ([editor this]) - (let-values ([(x y) (send editor dc-location-to-editor-location event-x event-y)]) - (cond - [(is-a? editor text%) - (let ([pos (send editor find-position x y #f on-it?)]) - (cond - [(not (unbox on-it?)) (values #f #f)] - [else - (let ([snip (send editor find-snip pos 'after-or-none)]) - (if (and snip (is-a? snip editor-snip%)) - (loop (send snip get-editor)) - (values pos editor)))]))] - [(is-a? editor pasteboard%) - (define snip (send editor find-snip x y)) - (if (and snip (is-a? snip editor-snip%)) - (loop (send snip get-editor)) - (values #f #f))] - [else (values #f #f)])))) + (define-values (x y) (send editor dc-location-to-editor-location event-x event-y)) + (cond + [(is-a? editor text%) + (let ([pos (send editor find-position x y #f on-it?)]) + (cond + [(not (unbox on-it?)) (values #f #f)] + [else + (let ([snip (send editor find-snip pos 'after-or-none)]) + (if (and snip (is-a? snip editor-snip%)) + (loop (send snip get-editor)) + (values pos editor)))]))] + [(is-a? editor pasteboard%) + (define snip (send editor find-snip x y)) + (if (and snip (is-a? snip editor-snip%)) + (loop (send snip get-editor)) + (values #f #f))] + [else (values #f #f)]))) ;; text% start -> (values left top right bottom) ;; (four numbers that indicate the locations in pixels of the @@ -319,40 +317,39 @@ id frames (lambda (val wr) - (let ([id-sym (syntax-e id)] - [menu (make-object popup-menu% #f)]) - (make-object - menu-item% - (clean-status (format "Print value of ~a to console" id-sym)) - menu - (lambda (item evt) - (send (get-tab) print-to-console (format "~a = ~s" id-sym val)))) - (make-object - menu-item% - (format "(set! ~a ...)" id-sym) - menu - (lambda (item evt) - (define tmp - (get-text-from-user (format "New value for ~a" id-sym) - #f - #f - (format "~a" val))) - (when tmp - (let/ec k - (wr (with-handlers ([exn:fail? - (lambda (exn) - (message-box - "Debugger Error" - (format "The following error occurred: ~a" - (exn-message exn))) - (k))]) - (read (open-input-string tmp)))))))) - (send (get-canvas) - popup-menu - menu - (+ 1 (inexact->exact (floor (send event get-x)))) - (+ 1 (inexact->exact (floor (send event get-y))))) - #t)) + (define id-sym (syntax-e id)) + (define menu (make-object popup-menu% #f)) + (make-object menu-item% + (clean-status (format "Print value of ~a to console" id-sym)) + menu + (lambda (item evt) + (send (get-tab) print-to-console (format "~a = ~s" id-sym val)))) + (make-object + menu-item% + (format "(set! ~a ...)" id-sym) + menu + (lambda (item evt) + (define tmp + (get-text-from-user (format "New value for ~a" id-sym) + #f + #f + (format "~a" val))) + (when tmp + (let/ec k + (wr + (with-handlers ([exn:fail? (lambda (exn) + (message-box + "Debugger Error" + (format "The following error occurred: ~a" + (exn-message exn))) + (k))]) + (read (open-input-string tmp)))))))) + (send (get-canvas) + popup-menu + menu + (+ 1 (inexact->exact (floor (send event get-x)))) + (+ 1 (inexact->exact (floor (send event get-y))))) + #t) (lambda () #f)) (super on-event event))) @@ -462,25 +459,25 @@ [mouse-over-pos (set! mouse-over-pos #f) (invalidate-bitmap-cache)]) - (let* ([frames (send (get-tab) get-stack-frames)] - [pos-vec (send (get-tab) get-pos-vec)] - [id (robust-vector-ref pos-vec pos)] - ;; Try to look up the identifier and render its value. If either - ;; of these steps fails, just draw an empty string in the status bar. - [rendered (lookup-var - id - (list-tail frames (send (get-tab) get-frame-num)) - ;; id found - (lambda (val _) - (cond - [(render val) - => - (lambda (str) - (string-append (symbol->string (syntax-e id)) " = " str))] - [else ""])) - ;; id not found - (lambda () ""))]) - (send (get-tab) set-mouse-over-msg (clean-status rendered)))))) + (define frames (send (get-tab) get-stack-frames)) + (define pos-vec (send (get-tab) get-pos-vec)) + (define id (robust-vector-ref pos-vec pos)) + ;; Try to look up the identifier and render its value. If either + ;; of these steps fails, just draw an empty string in the status bar. + (define rendered + (lookup-var id + (list-tail frames (send (get-tab) get-frame-num)) + ;; id found + (lambda (val _) + (cond + [(render val) + => + (lambda (str) + (string-append (symbol->string (syntax-e id)) " = " str))] + [else ""])) + ;; id not found + (lambda () ""))) + (send (get-tab) set-mouse-over-msg (clean-status rendered))))) (super on-event event)] [(send event button-down? 'right) (debugger-handle-right-click event breakpoints)] [else (super on-event event)])) @@ -520,50 +517,56 @@ ;; 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 - (let* ([frame-defs (send (get-tab) defs-containing-current-frame)] - [pos (send (get-tab) get-current-frame-endpoints)] - [start (and pos (first pos))] - [end (and pos (second pos))] - [frame-num (send (get-tab) get-frame-num)] - [break-status (send (get-tab) get-break-status)]) - (when (and (eq? frame-defs this) start end) - (let*-values ([(xl yl xr yr) (find-char-box this start)] - [(ym) (average yl yr)] - [(xa ya xb yb) (find-char-box this end)] - [(diameter) (- xb xa)] - [(yoff) (/ (- yb ya diameter) 2)] - [(ym2) (average ya yb)]) - (let ([op (send dc get-pen)] - [ob (send dc get-brush)]) - (cond - [(and (zero? frame-num) - (eq? break-status 'error)) - (send dc set-pen pc-err-pen) - (send dc set-brush pc-err-brush)] - [(and (zero? frame-num) - (eq? break-status 'break)) - (send dc set-pen pc-brk-pen) - (send dc set-brush pc-brk-brush)] - [(zero? frame-num) - (send dc set-pen pc-pen) - (send dc set-brush pc-brush)] - [else - (send dc set-pen pc-up-stack-pen) - (send dc set-brush pc-up-stack-brush)]) - (unless (and (zero? frame-num) (cons? break-status)) - ;; mark the beginning of the expression with a triangle - (send dc draw-polygon (list (make-object point% xl yl) - (make-object point% xl yr) - (make-object point% xr ym)) dx dy)) - (if (and (zero? frame-num) (cons? break-status)) - ;; top frame, end: mark the end of the expression with a triangle - (send dc draw-polygon (list (make-object point% xa ya) - (make-object point% xa yb) - (make-object point% xb ym2)) dx dy) - ;; otherwise: make the end of the expression with a circle - (send dc draw-ellipse (+ xa dx) (+ ya dy yoff) diameter diameter)) - (send dc set-pen op) - (send dc set-brush ob))))))) + (define frame-defs (send (get-tab) defs-containing-current-frame)) + (define pos (send (get-tab) get-current-frame-endpoints)) + (define start (and pos (first pos))) + (define end (and pos (second pos))) + (define frame-num (send (get-tab) get-frame-num)) + (define break-status (send (get-tab) get-break-status)) + (when (and (eq? frame-defs this) start end) + (let*-values ([(xl yl xr yr) (find-char-box this start)] + [(ym) (average yl yr)] + [(xa ya xb yb) (find-char-box this end)] + [(diameter) (- xb xa)] + [(yoff) (/ (- yb ya diameter) 2)] + [(ym2) (average ya yb)]) + (let ([op (send dc get-pen)] + [ob (send dc get-brush)]) + (cond + [(and (zero? frame-num) (eq? break-status 'error)) + (send dc set-pen pc-err-pen) + (send dc set-brush pc-err-brush)] + [(and (zero? frame-num) (eq? break-status 'break)) + (send dc set-pen pc-brk-pen) + (send dc set-brush pc-brk-brush)] + [(zero? frame-num) + (send dc set-pen pc-pen) + (send dc set-brush pc-brush)] + [else + (send dc set-pen pc-up-stack-pen) + (send dc set-brush pc-up-stack-brush)]) + (unless (and (zero? frame-num) (cons? break-status)) + ;; mark the beginning of the expression with a triangle + (send dc + draw-polygon + (list (make-object point% xl yl) + (make-object point% xl yr) + (make-object point% xr ym)) + dx + dy)) + (if (and (zero? frame-num) (cons? break-status)) + ;; top frame, end: mark the end of the expression with a triangle + (send dc + draw-polygon + (list (make-object point% xa ya) + (make-object point% xa yb) + (make-object point% xb ym2)) + dx + dy) + ;; otherwise: make the end of the expression with a circle + (send dc draw-ellipse (+ xa dx) (+ ya dy yoff) diameter diameter)) + (send dc set-pen op) + (send dc set-brush ob)))))) (define/augment (after-set-next-settings s) (let ([tlw (get-top-level-window)]) @@ -893,12 +896,12 @@ (suspend-gui (get-stack-frames) (get-break-status) #t #t)) (define/public (resume) - (let ([v (get-break-status)]) - ;; We should be suspended here, so the user thread should be waiting for a value - ;; on resume-ch. However, we set a timeout to guard against cases where - ;; the user thread gets interrupted or killed unexpectedly. - (when (sync/timeout 1 (channel-put-evt resume-ch (and (pair? v) (cdr v)))) - (resume-gui)))) + (define v (get-break-status)) + ;; We should be suspended here, so the user thread should be waiting for a value + ;; on resume-ch. However, we set a timeout to guard against cases where + ;; the user thread gets interrupted or killed unexpectedly. + (when (sync/timeout 1 (channel-put-evt resume-ch (and (pair? v) (cdr v)))) + (resume-gui))) (define/public (set-mouse-over-msg msg) (send (get-frame) set-mouse-over-msg msg)) @@ -969,17 +972,16 @@ [v (truncate-value v 100 5)]) (do-in-user-thread (lambda () - (let ([s (open-output-string)]) - (send (drscheme:language-configuration:language-settings-language - current-language-settings) - render-value - v - (drscheme:language-configuration:language-settings-settings - current-language-settings) - s) - ;; Set a timeout in the user thread, so we don't block forever if the - ;; drscheme thread gives up waiting for our response. - (sync/timeout 1 (channel-put-evt result-ch (get-output-string s)))))) + (define s (open-output-string)) + (send + (drscheme:language-configuration:language-settings-language current-language-settings) + render-value + v + (drscheme:language-configuration:language-settings-settings current-language-settings) + s) + ;; Set a timeout in the user thread, so we don't block forever if the + ;; drscheme thread gives up waiting for our response. + (sync/timeout 1 (channel-put-evt result-ch (get-output-string s))))) ;; Set a timeout to guard against cases where the user thread ;; gets interrupted or killed in the middle of evaluation. (sync/timeout 1 result-ch)))) @@ -1182,23 +1184,21 @@ (send mouse-over-message set-label msg))) (define/public (debug-callback) - (let ([tab (get-current-tab)]) - (cond - [(eq? tab (send tab get-primary)) - (set! debug? #t) - (execute-callback) - (set! debug? #f)] - [else - (already-debugging tab)]))) + (define tab (get-current-tab)) + (cond + [(eq? tab (send tab get-primary)) + (set! debug? #t) + (execute-callback) + (set! debug? #f)] + [else (already-debugging tab)])) (define/override (execute-callback) - (let ([tab (get-current-tab)]) - (cond - [(eq? tab (send tab get-primary)) - (send (get-current-tab) prepare-execution debug?) - (super execute-callback)] - [else - (already-debugging tab)]))) + (define tab (get-current-tab)) + (cond + [(eq? tab (send tab get-primary)) + (send (get-current-tab) prepare-execution debug?) + (super execute-callback)] + [else (already-debugging tab)])) (define/private (already-debugging tab) (message-box From 3f79252f395e9baaaafedd0250bf04a782c40890 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:11:57 +0000 Subject: [PATCH 2/6] Fix 2 occurrences of `if-let-to-cond` `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting --- .../private/standalone-module-browser.rkt | 23 ++-- drracket/gui-debugger/debug-tool.rkt | 104 +++++++++--------- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/drracket-tool-lib/drracket/private/standalone-module-browser.rkt b/drracket-tool-lib/drracket/private/standalone-module-browser.rkt index 84651147a..816a35835 100644 --- a/drracket-tool-lib/drracket/private/standalone-module-browser.rkt +++ b/drracket-tool-lib/drracket/private/standalone-module-browser.rkt @@ -461,17 +461,18 @@ (set! update-label (λ (s) - (if (and s (not (null? s))) - (let* ([currently-over (car s)] - [fn (send currently-over get-filename)] - [lines (send currently-over get-lines)]) - (when (and fn lines) - (define label (format filename-constant fn lines)) - (define pkg (send currently-over get-pkg)) - (when pkg - (set! label (string-append (format pkg-constant pkg) " " label))) - (send label-message set-label label))) - (send label-message set-label "")))) + (cond + [(and s (not (null? s))) + (define currently-over (car s)) + (define fn (send currently-over get-filename)) + (define lines (send currently-over get-lines)) + (when (and fn lines) + (define label (format filename-constant fn lines)) + (define pkg (send currently-over get-pkg)) + (when pkg + (set! label (string-append (format pkg-constant pkg) " " label))) + (send label-message set-label label))] + [else (send label-message set-label "")]))) (send pasteboard set-name-length diff --git a/drracket/gui-debugger/debug-tool.rkt b/drracket/gui-debugger/debug-tool.rkt index 72d5b921d..4ef4877d9 100644 --- a/drracket/gui-debugger/debug-tool.rkt +++ b/drracket/gui-debugger/debug-tool.rkt @@ -362,62 +362,62 @@ (hash-set! breakpoints pos (not break-status)) (invalidate-bitmap-cache))) (let ([pc (send (get-tab) get-pc)]) - (if (and pc (= pos pc)) - (let* ([stat (send (get-tab) get-break-status)] - [f (get-top-level-window)] - [rendered-value - (if (cons? stat) - (if (= 2 (length stat)) - (render (cadr stat)) - (format "~s" - (cons 'values (map (lambda (v) (render v)) (rest stat))))) - "")]) - (when (cons? stat) - (make-object menu-item% - "Print return value to console" - menu - (lambda _ - (send (get-tab) - print-to-console - (string-append "return val = " rendered-value))))) - (unless (eq? stat 'break) - (make-object - menu-item% - (if (cons? stat) "Change return value..." "Skip expression...") - menu - (lambda (item evt) - (let ([tmp (get-text-from-user "Return value" #f)]) - (when tmp - (let/ec k - (send - (get-tab) - set-break-status - (cons 'exit-break - (call-with-values - (lambda () - (with-handlers ([exn:fail? - (lambda (exn) - (message-box "Debugger Error" + (cond + [(and pc (= pos pc)) + (define stat (send (get-tab) get-break-status)) + (get-top-level-window) + (define rendered-value + (if (cons? stat) + (if (= 2 (length stat)) + (render (cadr stat)) + (format "~s" (cons 'values (map (lambda (v) (render v)) (rest stat))))) + "")) + (when (cons? stat) + (make-object menu-item% + "Print return value to console" + menu + (lambda _ + (send (get-tab) + print-to-console + (string-append "return val = " rendered-value))))) + (unless (eq? stat 'break) + (make-object + menu-item% + (if (cons? stat) "Change return value..." "Skip expression...") + menu + (lambda (item evt) + (let ([tmp (get-text-from-user "Return value" #f)]) + (when tmp + (let/ec k + (send (get-tab) + set-break-status + (cons 'exit-break + (call-with-values + (lambda () + (with-handlers ([exn:fail? (lambda (exn) + (message-box + "Debugger Error" (format "An error occurred: ~a" (exn-message exn)) #f '(ok)) - (k))]) - (read (open-input-string tmp)))) - list))) - (invalidate-bitmap-cache)))))))) - (make-object menu-item% - "Continue to this point" - menu - (lambda (item evt) - (hash-set! breakpoints - pos - (lambda () - (hash-set! breakpoints pos break-status) - #t)) - (invalidate-bitmap-cache) - (when (send (get-tab) get-stack-frames) - (send (get-tab) resume)))))) + (k))]) + (read (open-input-string tmp)))) + list))) + (invalidate-bitmap-cache)))))))] + [else + (make-object menu-item% + "Continue to this point" + menu + (lambda (item evt) + (hash-set! breakpoints + pos + (lambda () + (hash-set! breakpoints pos break-status) + #t)) + (invalidate-bitmap-cache) + (when (send (get-tab) get-stack-frames) + (send (get-tab) resume))))])) (send (get-canvas) popup-menu menu From 82d25f075c4c89cdfce78467d6e5ec9fa633a8cb Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:11:57 +0000 Subject: [PATCH 3/6] Fix 1 occurrence of `read-line-any` Specify a line mode of `'any` with `read-line` to avoid differences between Windows and other platforms. --- .../drracket/private/standalone-module-browser.rkt | 2 +- 1 file changed, 1 insertion(+), 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 816a35835..ce7bdb865 100644 --- a/drracket-tool-lib/drracket/private/standalone-module-browser.rkt +++ b/drracket-tool-lib/drracket/private/standalone-module-browser.rkt @@ -938,7 +938,7 @@ (call-with-input-file filename (λ (port) (let loop ([n 0]) - (define l (read-line port)) + (define l (read-line port 'any)) (if (eof-object? l) n (loop (+ n 1))))) From e76da73a87e2d97cd9aa80b929d442235aa6e21d Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:11:57 +0000 Subject: [PATCH 4/6] Fix 1 occurrence of `quasiquote-to-list` This quasiquotation is equialent to a simple `list` call. --- .../drracket/find-module-path-completions.rkt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) 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 7461aa265..50fd4567f 100644 --- a/drracket-tool-text-lib/drracket/find-module-path-completions.rkt +++ b/drracket-tool-text-lib/drracket/find-module-path-completions.rkt @@ -182,20 +182,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)]) From 8df270054d67eaee2d274c9d0d9a4491d3e5c41f Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:11:57 +0000 Subject: [PATCH 5/6] Fix 1 occurrence of `cond-else-cond-to-cond` The `else` clause of this `cond` expression is another `cond` expression and can be flattened. --- .../drracket/find-module-path-completions.rkt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) 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 50fd4567f..1583528e1 100644 --- a/drracket-tool-text-lib/drracket/find-module-path-completions.rkt +++ b/drracket-tool-text-lib/drracket/find-module-path-completions.rkt @@ -207,15 +207,12 @@ (for/list ([just-one (in-list link-content)]) (define-values (what pth) (apply values just-one)) (cond - [(string? what) - (list just-one)] - [else - (cond - [(safe-directory-exists? pth) - (for/list ([dir (in-list (safe-directory-list pth))] - #:when (safe-directory-exists? (build-path pth dir))) - (list (path->string dir) (build-path pth dir)))] - [else '()])]))))) + [(string? what) (list just-one)] + [(safe-directory-exists? pth) + (for/list ([dir (in-list (safe-directory-list pth))] + #:when (safe-directory-exists? (build-path pth dir))) + (list (path->string dir) (build-path pth dir)))] + [else '()]))))) (define-syntax-rule (thunk-and-quote e) (values (λ () e) 'e)) From 7b3c1673d5305e17337c07b69b917a5324aee3ff Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:11:57 +0000 Subject: [PATCH 6/6] Fix 1 occurrence of `hash-ref-with-constant-lambda-to-hash-ref-without-lambda` The lambda can be removed from the failure result in this `hash-ref` expression. --- drracket/gui-debugger/debug-tool.rkt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drracket/gui-debugger/debug-tool.rkt b/drracket/gui-debugger/debug-tool.rkt index 4ef4877d9..2f5b3301d 100644 --- a/drracket/gui-debugger/debug-tool.rkt +++ b/drracket/gui-debugger/debug-tool.rkt @@ -452,7 +452,7 @@ ;; mouse on breakable pos and hasn't moved significantly [(eq? pos mouse-over-pos)] ;; mouse on new breakable pos - [(not (eq? (hash-ref breakpoints pos (lambda () 'invalid)) 'invalid)) + [(not (eq? (hash-ref breakpoints pos 'invalid) 'invalid)) (set! mouse-over-pos pos) (invalidate-bitmap-cache)] ;; moved off breakable pos