[plt-scheme] Slideshow and pretty-print

From: yug at ios.ac.cn (yug at ios.ac.cn)
Date: Mon Nov 26 09:03:19 EST 2007

On Nov 26, 2007 8:56 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> Well, one more example:
>  (define code-test #'(code "DrScheme" "DrScheme"
>                            "DrScheme" (break one) (break two) "DrScheme"
>                            (break three) "DrScheme"))
>  (slide/center
>   (code #,code-test))
> This example will format the way you wanted; I changed the `quote' to a
> `quote-syntax', and source information is preserved with the syntax
> object.

  Thanks! I get your meaning.  Many of my sexp are composed in a way like

(define w-prog1 `(int w-test (,arg1) "{" (,d1 ,d2) ";;" ,w-prog1-s "}"))

It's a trial to change all the definitions, but I get the idea now.

> I always just select a range of text in DrScheme and hit Tab to
> reformat it. If new line breaks are needed to make the layout better, I
> put them in manually.

You missed my problem. I use scheme to modify scheme code, not manually

here is the code

(module subst mzscheme
  (require (lib "file.ss"))
  (require (lib "pretty.ss"))

  (define (sub before after source target)
    (let ([v ()])
      (call-with-input-file source
        (lambda (iport)
          (set! v (read iport))))
      (call-with-output-file target
        (lambda (oport)
          (pretty-print (tsub before after v) oport))

  (define (tsub origin after v)
    (if (list? v)
        (map (lambda (x)
               (tsub origin after x)) v)
        (if (equal? origin v)

the problem here is  when scheme "read iport", the comment is discarded,
only essential things are read.

If I use (read-line port), it's a complexed case analysis on the source
file. So ...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20071126/5846bdd6/attachment.html>

Posted on the users mailing list.