[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-racket ce1f555 085/191: Racket: capturing and displ
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-racket ce1f555 085/191: Racket: capturing and displaying standard error during evaluation |
Date: |
Sun, 1 Aug 2021 18:32:05 -0400 (EDT) |
branch: elpa/geiser-racket
commit ce1f5551148aa6745b7e06ef65716058e8d72c61
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Racket: capturing and displaying standard error during evaluation
This bugs was exposed by using rackunit, where all the output of, say,
check-eq? was lost for good (it was being sent to the stderr black
hole).
Hat tip Grant Retkke.
---
geiser/eval.rkt | 5 +++--
geiser/modules.rkt | 26 +++++++++++++++++---------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/geiser/eval.rkt b/geiser/eval.rkt
index a59e275..26ad959 100644
--- a/geiser/eval.rkt
+++ b/geiser/eval.rkt
@@ -47,8 +47,9 @@
(let ([output
(with-output-to-string
(lambda ()
- (with-handlers ([exn? set-last-error])
- (call-with-values thunk set-last-result))))])
+ (parameterize ([current-error-port (current-output-port)])
+ (with-handlers ([exn? set-last-error])
+ (call-with-values thunk set-last-result)))))])
(append last-result `((output . ,output)))))
(define (eval-in form spec lang)
diff --git a/geiser/modules.rkt b/geiser/modules.rkt
index 2c57db9..befe2bc 100644
--- a/geiser/modules.rkt
+++ b/geiser/modules.rkt
@@ -71,11 +71,14 @@
(define unknown-module-name "*unresolved module*")
+(define (unix-path->string path)
+ (regexp-replace* "\\\\" (path->string path) "/"))
+
(define (module-path-name->name path)
- (cond [(path? path) (module-path-name->name (path->string path))]
+ (cond [(path? path) (module-path-name->name (unix-path->string path))]
;; [(eq? path '#%kernel) "(kernel)"]
[(string? path)
- (let* ([cpaths (map (compose path->string path->directory-path)
+ (let* ([cpaths (map (compose unix-path->string path->directory-path)
(current-library-collection-paths))]
[prefix-len (lambda (p)
(let ((pl (string-length p)))
@@ -85,9 +88,9 @@
[lens (map prefix-len cpaths)]
[real-path (substring path (apply max lens))])
(if (absolute-path? real-path)
- (let-values ([(_ base __) (split-path path)])
- (path->string base))
- (regexp-replace "\\.[^./]*$" real-path "")))]
+ (let-values ([(_ base __) (split-path path)])
+ (unix-path->string base))
+ (regexp-replace "\\.[^./]*$" real-path "")))]
[(symbol? path) (symbol->string path)]
[else unknown-module-name]))
@@ -116,17 +119,22 @@
(lambda (_ basename __)
(member (path->string basename) '(".svn" "compiled")))))
-(define path->symbol (compose string->symbol path->string))
+(define path->symbol (compose string->symbol unix-path->string))
(define (path->entry path)
(let ([ext (filename-extension path)])
(and ext
(or (bytes=? ext #"rkt") (bytes=? ext #"ss"))
(not (bytes=? (bytes-append #"main" ext) (path->bytes path)))
- (let* ([path (path->string path)]
+ (let* ([path (unix-path->string path)]
[len (- (string-length path) (bytes-length ext) 1)])
(substring path 0 len)))))
+(define (ensure-path datum)
+ (if (string? datum)
+ (string->path datum)
+ datum))
+
(define main-rkt (build-path "main.rkt"))
(define main-ss (build-path "main.ss"))
@@ -144,7 +152,7 @@
[(file) (let ([entry (path->entry path)])
(if (not entry) acc (register entry path)))]
[(dir) (cond [(skippable-dir? path) (values acc #f)]
- [(find-main path) => (curry register (path->string path))]
+ [(find-main path) => (curry register (unix-path->string
path))]
[else (values acc reg?)])]
[else acc]))
@@ -175,7 +183,7 @@
(let-values ([(dir base ign) (split-path path)])
(and (or (equal? base main-rkt)
(equal? base main-ss))
- (map (lambda (m) (path->string (build-path dir m)))
+ (map (lambda (m) (unix-path->string (build-path dir m)))
(remove "main" ((find-modules #f) dir '())))))))
(define (known-modules)
- [nongnu] elpa/geiser-racket e469ace 134/191: For crazy guys that use (define/match [foo bar] ...), (continued)
- [nongnu] elpa/geiser-racket e469ace 134/191: For crazy guys that use (define/match [foo bar] ...), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 0c9d6c3 055/191: Guile reconnected (but not debuggable (yet)), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket fbbd3ab 060/191: Superior schemes, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 58657b4 056/191: Better EOT token for more robust communication, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket fd14450 062/191: Support for implementation-specific font lock keywords, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 309ca6d 069/191: Racket: more information in symbol documentation, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket a787a26 071/191: Bug fix: don't intern symbols read by scheme reader, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c4b8c1a 080/191: Racket: geiser-add-to-load-path implemented, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket a9405d0 095/191: Racket: reading into elisp-land the cache dir as needed, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 20cc118 083/191: Leftover code from the previous patch removed, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket ce1f555 085/191: Racket: capturing and displaying standard error during evaluation,
Philip Kaludercic <=
- [nongnu] elpa/geiser-racket c9008a6 091/191: [WIP] Draw images inline in the Racket REPL., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 62e2006 114/191: Indentation for Racket's struct, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 0be1797 122/191: A better solution to the funky filename problem, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket e17099e 166/191: Skip expression quote when getting a racket symbol, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 3079c3a 163/191: Racket: displaying graphics in structured objects, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket c0a617f 173/191: Begin the summary lines of all elisp libraries with three semicolons, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 99acb21 175/191: Fix indentation, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 6bc2bc2 176/191: Fix indentation, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 74a223e 008/191: Racket: autodoc for struct constructors, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-racket 4c3903a 063/191: Better module help, Philip Kaludercic, 2021/08/01