From 7eb3e8c28aacd14c4422d96e2d9e79d6910261b0 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 2 Jan 2011 10:00:46 -0600 Subject: [PATCH] change drracket and framework so they don't rebind printf anymore (instead binding oprintf to print to the original output port of drracket) --- collects/drracket/private/debug.rkt | 5 +---- collects/drracket/private/language.rkt | 6 +----- collects/drracket/private/rep.rkt | 11 ++++------- collects/drracket/private/syncheck/gui.rkt | 6 ++---- collects/framework/private/text.rkt | 11 +---------- 5 files changed, 9 insertions(+), 30 deletions(-) diff --git a/collects/drracket/private/debug.rkt b/collects/drracket/private/debug.rkt index d06a46621a..cbf6abd678 100644 --- a/collects/drracket/private/debug.rkt +++ b/collects/drracket/private/debug.rkt @@ -28,6 +28,7 @@ profile todo: (for-syntax racket/base)) (define orig (current-output-port)) +(define (oprintf . args) (apply fprintf orig args)) (provide debug@) (define-unit debug@ @@ -39,10 +40,6 @@ profile todo: [prefix drracket:init: drracket:init^]) (export drracket:debug^) - - (define (printf . args) (apply fprintf orig args)) - - ; ; ; ; diff --git a/collects/drracket/private/language.rkt b/collects/drracket/private/language.rkt index 48e206cc1d..5616903885 100644 --- a/collects/drracket/private/language.rkt +++ b/collects/drracket/private/language.rkt @@ -1,8 +1,4 @@ #lang racket/unit -;; WARNING: printf is rebound in this module to always use the -;; original stdin/stdout of drscheme, instead of the -;; user's io ports, to aid any debugging printouts. -;; (esp. useful when debugging the users's io) (require "drsig.rkt" string-constants @@ -36,7 +32,7 @@ (export drracket:language^) (define original-output-port (current-output-port)) - (define (printf . args) (apply fprintf original-output-port args)) + (define (oprintf . args) (apply fprintf original-output-port args)) (define-struct text/pos (text start end)) ;; text/pos = (make-text/pos (instanceof text% number number)) diff --git a/collects/drracket/private/rep.rkt b/collects/drracket/private/rep.rkt index c608fe814f..7f23ebe30c 100644 --- a/collects/drracket/private/rep.rkt +++ b/collects/drracket/private/rep.rkt @@ -15,11 +15,6 @@ TODO ; =Handler= means in the handler thread of some eventspace; it must ; be combined with either =Kernel= or =User= -;; WARNING: printf is rebound in this module to always use the -;; original stdin/stdout of drscheme, instead of the -;; user's io ports, to aid any debugging printouts. -;; (esp. useful when debugging the users's io) - (require racket/class racket/path racket/pretty @@ -40,6 +35,10 @@ TODO (provide rep@ with-stack-checkpoint) +(define orig-output-port (current-output-port)) +(define (oprintf . args) (apply fprintf orig-output-port args)) + + ;; run a thunk, and if an exception is raised, make it possible to cut the ;; stack so that the surrounding context is hidden (define checkpoints (make-weak-hasheq)) @@ -334,8 +333,6 @@ TODO ;; queue is full): (define output-limit-size 2000) - (define (printf . args) (apply fprintf drracket:init:original-output-port args)) - (define setup-scheme-interaction-mode-keymap (λ (keymap) (define (beginning-of-line text select?) diff --git a/collects/drracket/private/syncheck/gui.rkt b/collects/drracket/private/syncheck/gui.rkt index 8737c60333..3a59c5d700 100644 --- a/collects/drracket/private/syncheck/gui.rkt +++ b/collects/drracket/private/syncheck/gui.rkt @@ -47,8 +47,8 @@ If the namespace does not, they are colored the unbound color. "traversals.rkt") (provide tool@) -(define o (current-output-port)) -(define (oprintf . args) (apply fprintf o args)) +(define orig-output-port (current-output-port)) +(define (oprintf . args) (apply fprintf orig-output-port args)) (define status-init (string-constant cs-status-init)) (define status-coloring-program (string-constant cs-status-coloring-program)) @@ -86,8 +86,6 @@ If the namespace does not, they are colored the unbound color. (drracket:unit:add-to-program-editor-mixin clearing-text-mixin)) (define (phase2) (void)) - (define (printf . args) (apply fprintf o args)) - ;;; ;;; ;;; ;;;;; ; ; ; ; ; ; ; ; ; ; diff --git a/collects/framework/private/text.rkt b/collects/framework/private/text.rkt index 327309413c..277b1c5f65 100644 --- a/collects/framework/private/text.rkt +++ b/collects/framework/private/text.rkt @@ -1,10 +1,4 @@ #lang racket/unit -#| - -WARNING: printf is rebound in the body of the unit to always - print to the original output port. - -|# (require string-constants racket/unit @@ -37,10 +31,7 @@ WARNING: printf is rebound in the body of the unit to always (init-depend framework:editor^) (define original-output-port (current-output-port)) -(define (printf . args) - (apply fprintf original-output-port args) - (void)) - +(define (oprintf . args) (apply fprintf original-output-port args)) (define-struct range (start end caret-space? style color) #:inspector #f) (define-struct rectangle (left top right bottom style color) #:inspector #f)