[racket] [Resolved] slideshow/pict: typeset-code on programmatically generated syntax objects?

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Mon Sep 16 11:19:01 EDT 2013

I added a #'(code:line) after form and before the tag-pict. That did the trick.
-Ian
----- Original Message -----
From: "J. Ian Johnson" <ianj at ccs.neu.edu>
To: "users" <users at racket-lang.org>
Sent: Monday, September 16, 2013 11:17:16 AM GMT -05:00 US/Canada Eastern
Subject: [racket] slideshow/pict: typeset-code on programmatically generated syntax objects?

I'm creating a picture of a program that has one form in it that I want to highlight. I'm reading the program in with read-syntax with parameterization [port-count-lines-enabled #t], and the form I want to introduce gets spliced in the middle after reading, as the result of the code macro.

This form is not on its own line; instead it appears right at the end of the previous form.
Question: How can I make it render on its own line?

The code follows, where proctime.rkt is just used as a long enough file to make my point visually.

(define (dinky) 
  (code (code:line)
        (code:line (define (dinky-helper-function x lst)
                     (map (λ (y) (- y x)) lst)))))

(define (a-program)
  (parameterize ([port-count-lines-enabled #t])
   (with-input-from-file "proctime.rkt"
     (λ ()
        (read-line)
        (define all-forms-rev
          (for/fold ([acc '()])
              ([form (in-port read-syntax)]
               [i (in-naturals)])
            (define stuff
              (list 'code
                    (syntax-line form)
                    (syntax-column form)
                    (syntax-position form)
                    (syntax-span form)))
            (cons (datum->syntax #f
                                 (list #'code:line form)
                                 stuff) acc)))
        (define len (length all-forms-rev))
        (typeset-code
         (datum->syntax
          #f
          (for/fold ([acc '()]) ([form (in-list all-forms-rev)]
                                 [i (in-naturals)])
            (cond
             [(= i (quotient len 2))
              (list* form (tag-pict (dinky) 'helper) acc)]
             [else (cons form acc)]))))))))

____________________
  Racket Users list:
  http://lists.racket-lang.org/users


Posted on the users mailing list.