<div dir="ltr">Why not just use the pp argument that&#39;s already there? (And I think your editor is indenting improperly; some of those lines don&#39;t seem to have changed except indentation)<div><br></div><div>Robby</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 2, 2013 at 3:02 PM, J. Ian Johnson <span dir="ltr">&lt;<a href="mailto:ianj@ccs.neu.edu" target="_blank">ianj@ccs.neu.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Okay, here&#39;s a diff that hacks it in for my purposes and doesn&#39;t crash. I don&#39;t know what this breaks due to the new init-field in size-snip though. Will anyone familiar with this part of the codebase please comment?<br>

Thanks,<br>
-Ian<br>
<br>
diff --git a/collects/redex/gui.rkt b/collects/redex/gui.rkt<br>
index 41dce2a..ddd291b 100644<br>
--- a/collects/redex/gui.rkt<br>
+++ b/collects/redex/gui.rkt<br>
@@ -43,6 +43,7 @@<br>
                #:edge-label-font (or/c #f (is-a?/c font%))<br>
                #:edge-labels? boolean?<br>
                #:filter (-&gt; any/c (or/c #f string?) any/c)<br>
+               #:format (-&gt; any/c any/c)<br>
                #:graph-pasteboard-mixin (make-mixin-contract graph-pasteboard&lt;%&gt;))<br>
               any)]<br>
  [traces/ps (-&gt;* (reduction-relation?<br>
@@ -60,6 +61,7 @@<br>
                   #:edge-label-font (or/c #f (is-a?/c font%))<br>
                   #:edge-labels? boolean?<br>
                   #:filter (-&gt; any/c (or/c #f string?) any/c)<br>
+                  #:format (-&gt; any/c any/c)<br>
                   #:graph-pasteboard-mixin (make-mixin-contract graph-pasteboard&lt;%&gt;)<br>
                   #:post-process (-&gt; (is-a?/c graph-pasteboard&lt;%&gt;) any/c))<br>
                  any)]<br>
diff --git a/collects/redex/private/size-snip.rkt b/collects/redex/private/size-snip.rkt<br>
index e505ba5..3cf8676 100644<br>
--- a/collects/redex/private/size-snip.rkt<br>
+++ b/collects/redex/private/size-snip.rkt<br>
@@ -83,6 +83,7 @@<br>
 (define size-editor-snip%<br>
   (class* editor-snip% (reflowing-snip&lt;%&gt;)<br>
     (init-field expr)<br>
+    (init-field formatted-expr)<br>
     (init pp)<br>
     (init-field char-width)<br>
     (define real-pp<br>
@@ -172,7 +173,7 @@<br>
           (send text thaw-colorer))<br>
         (send text set-styles-sticky #f)<br>
         (send text erase)<br>
-        (real-pp expr port char-width text)<br>
+        (real-pp formatted-expr port char-width text)<br>
diff --git a/collects/redex/private/traces.rkt b/collects/redex/private/traces.rkt<br>
index 1293c19..9bcb45a 100644<br>
--- a/collects/redex/private/traces.rkt<br>
+++ b/collects/redex/private/traces.rkt<br>
@@ -139,6 +139,7 @@<br>
                    #:edge-labels? [edge-labels? #t]<br>
                    #:graph-pasteboard-mixin [extra-graph-pasteboard-mixin values]<br>
                    #:filter [term-filter (lambda (x y) #t)]<br>
+                   #:format [term-formatter values]<br>
                    #:post-process [post-process void]<br>
                    #:x-spacing [x-spacing default-x-spacing]<br>
                    #:y-spacing [y-spacing default-x-spacing])<br>
@@ -156,6 +157,7 @@<br>
                         #:edge-labels? edge-labels?<br>
                         #:graph-pasteboard-mixin extra-graph-pasteboard-mixin<br>
                         #:filter term-filter<br>
+                        #:format term-formatter<br>
                         #:x-spacing x-spacing<br>
                         #:y-spacing y-spacing)])<br>
     (post-process graph-pb)<br>
@@ -249,6 +251,7 @@<br>
                 #:edge-label-font [edge-label-font #f]<br>
                 #:edge-labels? [edge-labels? #t]<br>
                 #:filter [term-filter (lambda (x y) #t)]<br>
+                #:format [term-formatter values]<br>
                 #:graph-pasteboard-mixin [extra-graph-pasteboard-mixin values]<br>
                 #:no-show-frame? [no-show-frame? #f]<br>
                 #:x-spacing [x-spacing default-x-spacing]<br>
@@ -368,7 +371,7 @@<br>
     (filter<br>
      (λ (x) x)<br>
      (map (lambda (expr) (apply build-snip<br>
-                                snip-cache #f expr pred pp #f code-colors?<br>
+                                snip-cache #f expr pred term-formatter pp #f code-colors?<br>
                                 (get-user-char-width user-char-width expr)<br>
                                 default-colors))<br>
           exprs)))<br>
@@ -429,20 +432,20 @@<br>
            (let* ([snip (car snips)]<br>
                   [new-snips<br>
                    (filter<br>
-                    (lambda (x) x)<br>
+                    values<br>
                     (map (lambda (red+sexp)<br>
                            (let-values ([(name sexp) (apply values red+sexp)])<br>
                              (call-on-eventspace-main-thread<br>
                               (λ ()<br>
-                                (and (term-filter sexp name)<br>
-                                     (let-values ([(dark-arrow-color light-arrow-color dark-label-color light-label-color<br>
-                                                                     dark-pen-color<br>
-                                                                     light-pen-color)<br>
-                                                   (red-&gt;colors name)])<br>
-                                       (build-snip snip-cache snip sexp pred pp name code-colors?<br>
-                                                   (get-user-char-width user-char-width sexp)<br>
-                                                   light-arrow-color dark-arrow-color dark-label-color light-label-color<br>
-                                                   dark-pen-color light-pen-color)))))))<br>
+                                 (and (term-filter sexp name)<br>
+                                      (let-values ([(dark-arrow-color light-arrow-color dark-label-color light-label-color<br>
+                                                                      dark-pen-color<br>
+                                                                      light-pen-color)<br>
+                                                    (red-&gt;colors name)])<br>
+                                        (build-snip snip-cache snip sexp pred term-formatter pp name code-colors?<br>
+                                                    (get-user-char-width user-char-width sexp)<br>
+                                                    light-arrow-color dark-arrow-color dark-label-color light-label-color<br>
+                                                    dark-pen-color light-pen-color)))))))<br>
                          (apply-reduction-relation/tag-with-names reductions (send snip get-expr))))]<br>
                   [new-y<br>
                    (call-on-eventspace-main-thread<br>
@@ -787,6 +790,7 @@<br>
 ;;              (union #f (is-a?/c graph-snip&lt;%&gt;))<br>
 ;;              sexp<br>
 ;;              sexp -&gt; boolean<br>
+;;              sexp -&gt; sexp<br>
 ;;              (any port number -&gt; void)<br>
 ;;              (union #f string)<br>
 ;;              number<br>
@@ -795,7 +799,7 @@<br>
 ;; returns #f if a snip corresponding to the expr has already been created.<br>
 ;; also adds in the links to the parent snip<br>
 ;; =eventspace main thread=<br>
-(define (build-snip cache parent-snip expr pred pp name code-colors? cw<br>
+(define (build-snip cache parent-snip expr pred formatter pp name code-colors? cw<br>
                     light-arrow-color dark-arrow-color dark-label-color light-label-color<br>
                     dark-brush-color light-brush-color)<br>
   (let-values ([(snip new?)<br>
@@ -804,7 +808,7 @@<br>
                            cache<br>
                            expr<br>
                            (lambda ()<br>
-                             (let ([new-snip (make-snip parent-snip expr pred pp code-colors? cw)])<br>
+                             (let ([new-snip (make-snip parent-snip expr pred formatter pp code-colors? cw)])<br>
                                (hash-set! cache expr new-snip)<br>
@@ -824,7 +828,7 @@<br>
                                  (make-object color% light-label-color))<br>
                              0 0<br>
                              name)<br>
-      (update-badness pred parent-snip (send parent-snip get-expr)))<br>
+      (update-badness pred parent-snip (formatter (send parent-snip get-expr))))<br>
<br>
     (update-badness pred snip expr)<br>
<br>
@@ -845,20 +849,22 @@<br>
 ;; make-snip : (union #f (is-a?/c graph-snip&lt;%&gt;))<br>
 ;;             sexp<br>
 ;;             sexp -&gt; boolean<br>
+;;             sexp -&gt; sexp<br>
 ;;             (any port number -&gt; void)<br>
 ;;             boolean<br>
 ;;             number<br>
 ;;          -&gt; (is-a?/c graph-editor-snip%)<br>
 ;; unconditionally creates a new graph-editor-snip<br>
 ;; =eventspace main thread=<br>
-(define (make-snip parent-snip expr pred pp code-colors? cw)<br>
+(define (make-snip parent-snip expr pred formatter pp code-colors? cw)<br>
   (let* ([text (new program-text%)]<br>
          [es (instantiate graph-editor-snip% ()<br>
                (char-width cw)<br>
                (editor text)<br>
                (my-eventspace (current-eventspace))<br>
                (pp pp)<br>
-               (expr expr))])<br>
+               (expr expr)<br>
+               (formatted-expr (formatter expr)))])<br>
     (send text set-autowrap-bitmap #f)<br>
     (send text set-max-width &#39;none)<br>
     (send text freeze-colorer)<br>
<div class="HOEnZb"><div class="h5"><br>
----- Original Message -----<br>
From: &quot;J. Ian Johnson&quot; &lt;<a href="mailto:ianj@ccs.neu.edu">ianj@ccs.neu.edu</a>&gt;<br>
To: &quot;users&quot; &lt;<a href="mailto:users@racket-lang.org">users@racket-lang.org</a>&gt;<br>
Sent: Thursday, May 2, 2013 2:46:17 PM GMT -05:00 US/Canada Eastern<br>
Subject: [racket] Trimmed view in redex&#39;s traces?<br>
<br>
I&#39;m trying to debug an abstract machine with some large auxiliary tables. Is there a way to make traces only show a portion of a term, but still treat the box it&#39;s in as the entire term? An additional bonus would be to drill down into a trimmed box via click or something.<br>

I don&#39;t see this in the docs, so I&#39;m guessing no, but an extra keyword argument for a term -&gt; term &quot;trimming&quot; function shouldn&#39;t be too hard to add, right? Just not sure where to change this.<br>

-Ian<br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br></div>