[plt-scheme] Slideshow and pretty-print

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Nov 26 07:56:43 EST 2007

At Mon, 26 Nov 2007 20:41:25 +0800, yug at ios.ac.cn wrote:
> Hi, Matthew:
> 
> Slideshow's `code' layout depends on the layout of the source. To get
> > the layout information, the source needs to be literally within a
> > `code' form.
> >
> 
>  I have tried other ways, all fails
> 
> So , I have to copy/paste the source code in the my slides:-(

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.

The above strategy won't work if you want to compile the above source,
because the compiled form of `quote-syntax' drops source information.
But if you want to read code out of a file at run time, then using
`read-syntax' instead of `read' should work fine.

> > > 2. How can I reserve the annotations when I apply pretty-print ?
> >
> > I'm not sure I understand the question.
> >
> 
> I have many replace work to handle in my scheme source code , any time when
> I modify the source code, it appears hard to read
> 
> so I use  pretty-print.  but ,the annotations lost
> 
> here is the code:
> 
>   (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))
>         'truncate)))
> 
> Yes, I can strip off the pretty-print on "(tsub before after v)"
> 
> but, it is hard to read that file, any suggestions?

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.

Matthew



Posted on the users mailing list.