<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>On Aug 8, 2009, at 4:52 PM, Robby Findler wrote:</div><blockquote type="cite">Do you get a stacktrace with the error message?</blockquote><div><br></div><div>Not in the test frame. But I do if I attempt to paste it into the Interactions REPL. See below.</div><div><br></div><div>I'd been kind of wondering how I might figure out where a #f is being passed in place of an editor, without making changes to the private code -- tricky (or at least tedious) given all the callbacks involved, and didn't seem worth it for an uncertain payoff before inquiring here.</div><div><br></div><div>jmj<br><div><br></div><div>-------</div><div><div>set-editor method of editor-snip%: expects argument of type <interface:editor% instance>; given #f</div><div><br></div><div> === context ===</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/editor-snip.ss:125:2: set-editor method in editor-snip%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/snip.ss:1178:2: read method in editor-snip-class%</div><div>for-loop</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/editor.ss:600:2: read-snips-from-file method in editor%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/editor.ss:1034:2: do-buffer-paste method in editor%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/text.ss:2055:2: do-paste method in text%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/text.ss:2087:2: core</div><div>/Applications/PLT Scheme v4.2/collects/framework/private/standard-menus.ss:382:4: edit-menu:paste-callback method in ...te/standard-menus.ss:179:2</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:485:2: chain-handle-key-event method in keymap%</div><div>for-loop</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:485:2: chain-handle-key-event method in keymap%</div><div>for-loop</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:485:2: chain-handle-key-event method in keymap%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:441:2: handle-key-event method in keymap%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxmenu.ss:56:23</div><div>/Applications/PLT Scheme v4.2/collects/scheme/private/more-scheme.ss:155:2: call-with-break-parameterization</div><div>...</div><div>-----------</div><div><br></div></div><div><br><div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font><br><br>Robby<br><br>On Sat, Aug 8, 2009 at 1:57 AM, Jordan Johnson<<a href="mailto:jmj@fellowhuman.com">jmj@fellowhuman.com</a>> wrote:<br><blockquote type="cite">Hi all,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I've been working on a snip implementation (representing an annotated<br></blockquote><blockquote type="cite">expression) and am getting a mysterious error. I'd be grateful for any help<br></blockquote><blockquote type="cite">the community can offer in solving the problem.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The error: Currently when I attempt to copy and paste my snip, I get the<br></blockquote><blockquote type="cite">error<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> set-editor method of editor-snip%: expects argument of type<br></blockquote><blockquote type="cite"><interface:editor% instance>; given #f<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">...and the editor-snip% in question is apparently not any of the snips I've<br></blockquote><blockquote type="cite">defined, which I've verified by overriding their set-editor method. This<br></blockquote><blockquote type="cite">error is coming from somewhere deep in MrEd, and (after embarrassingly many<br></blockquote><blockquote type="cite">hours of reading internal code and probing/rewriting) I don't see the cause.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Below is a version I've pared down to just what's necessary to see the<br></blockquote><blockquote type="cite">structure and exercise the bug. To reproduce the error: run it, evaluate<br></blockquote><blockquote type="cite">(test-w/text%), and attempt to copy and paste the editor-snip% you see in<br></blockquote><blockquote type="cite">the frame it created.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any observations?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks,<br></blockquote><blockquote type="cite">jmj<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;;;;; code-desc-simplified.ss<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">#lang scheme/gui<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">(require framework embedded-gui)<br></blockquote><blockquote type="cite">(provide anno-snip%)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;;;;;;;; Snipclassery (for cut/paste) ;;;;;;;;;;;<br></blockquote><blockquote type="cite">;; Design follows framework/private/comment-box.ss lines 23-31<br></blockquote><blockquote type="cite">(define anno-snipclass%<br></blockquote><blockquote type="cite"> (class decorated-editor-snipclass%<br></blockquote><blockquote type="cite"> (define/override (make-snip stream-in) (new anno-snip%))<br></blockquote><blockquote type="cite"> (define/override (read in)<br></blockquote><blockquote type="cite"> (let ([pb (new anno-pb%)])<br></blockquote><blockquote type="cite"> (let ([code-ed (send pb get-code-editor)]<br></blockquote><blockquote type="cite"> [anno-ed (send pb get-anno-editor)])<br></blockquote><blockquote type="cite"> (send code-ed read-from-file in 'start)<br></blockquote><blockquote type="cite"> (send anno-ed read-from-file in 'start))))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (super-new)))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">(define snipclass (make-object anno-snipclass%))<br></blockquote><blockquote type="cite">(send snipclass set-version 1)<br></blockquote><blockquote type="cite">(send snipclass set-classname "code-desc-snip.ss")<br></blockquote><blockquote type="cite">(send (get-the-snip-class-list) add snipclass)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;; Snip representing an annotated chunk of code.<br></blockquote><blockquote type="cite">(define anno-snip%<br></blockquote><blockquote type="cite"> (class decorated-editor-snip%<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (define/override (make-editor) (new anno-pb%))<br></blockquote><blockquote type="cite"> (define/override (make-snip) (new anno-snip%))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> ;; copy/paste:<br></blockquote><blockquote type="cite"> (inherit get-editor)<br></blockquote><blockquote type="cite"> (define/override (write stream-out)<br></blockquote><blockquote type="cite"> (let ([pb (get-editor)])<br></blockquote><blockquote type="cite"> (let ([code (send pb get-code-editor)]<br></blockquote><blockquote type="cite"> [anno (send pb get-anno-editor)])<br></blockquote><blockquote type="cite"> (send code write-to-file stream-out)<br></blockquote><blockquote type="cite"> (send anno write-to-file stream-out))))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (define/override (copy) ;; -> anno-snip%<br></blockquote><blockquote type="cite"> ;; return a copy of this snip<br></blockquote><blockquote type="cite"> (let ([s (new anno-snip%)])<br></blockquote><blockquote type="cite"> (send s set-editor (send (get-editor) copy-self))<br></blockquote><blockquote type="cite"> s))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (super-new)<br></blockquote><blockquote type="cite"> ))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">(define anno-pb%<br></blockquote><blockquote type="cite"> (let ()<br></blockquote><blockquote type="cite"> (define (find-owner-snip ed) ;; editor<%> -> (union #f editor-snip%)<br></blockquote><blockquote type="cite"> (let ([admin (send ed get-admin)])<br></blockquote><blockquote type="cite"> (and admin<br></blockquote><blockquote type="cite"> (admin . is-a? . editor-snip-editor-admin<%>)<br></blockquote><blockquote type="cite"> (send admin get-snip))))<br></blockquote><blockquote type="cite"> (define scheme+copy-self% ;; class for the code editor<br></blockquote><blockquote type="cite"> (class scheme:text% ;; (from framework/private/comment-box.ss)<br></blockquote><blockquote type="cite"> (inherit copy-self-to)<br></blockquote><blockquote type="cite"> (init-field [kind 'default])<br></blockquote><blockquote type="cite"> (define/override (copy-self)<br></blockquote><blockquote type="cite"> (let ([ed (new scheme+copy-self%)])<br></blockquote><blockquote type="cite"> (copy-self-to ed)<br></blockquote><blockquote type="cite"> ed))<br></blockquote><blockquote type="cite"> (super-new)<br></blockquote><blockquote type="cite"> (inherit set-max-undo-history)<br></blockquote><blockquote type="cite"> (set-max-undo-history 'forever)))<br></blockquote><blockquote type="cite"> (class aligned-pasteboard%<br></blockquote><blockquote type="cite"> (super-new)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> ;;;;;;; Component editors:<br></blockquote><blockquote type="cite"> ;; code-editor and anno-editor are the two text%s that contain the<br></blockquote><blockquote type="cite"> ;; code and annotation, respectively.<br></blockquote><blockquote type="cite"> ;; -> (union #f text%)<br></blockquote><blockquote type="cite"> (define/public (get-code-editor) code-editor)<br></blockquote><blockquote type="cite"> (define/public (make-code-editor) (new scheme+copy-self%<br></blockquote><blockquote type="cite"> [kind 'code]))<br></blockquote><blockquote type="cite"> ;; -> (union #f text%)<br></blockquote><blockquote type="cite"> (define/public (get-anno-editor) anno-editor)<br></blockquote><blockquote type="cite"> (define/public (make-anno-editor) (new text%))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (define code-editor (make-code-editor)) ;; code box's editor<br></blockquote><blockquote type="cite"> (define anno-editor (make-anno-editor)) ;; annotation box's<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> ;;;;;;; Container snips for the text editors:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (define val (new vertical-alignment% [parent this]))<br></blockquote><blockquote type="cite"> ;; Container for the code box. I'm using this for the ability to<br></blockquote><blockquote type="cite"> ;; show/hide the box:<br></blockquote><blockquote type="cite"> (define code-view (new vertical-alignment%<br></blockquote><blockquote type="cite"> [parent val]<br></blockquote><blockquote type="cite"> [show? #t]))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> ;; Installs stretchable editor snips, if none are already installed,<br></blockquote><blockquote type="cite"> ;; to contain the code and anno editors.<br></blockquote><blockquote type="cite"> ;; (Does nothing if they already are installed, and returns #f.)<br></blockquote><blockquote type="cite"> ;; Returns #t if successful.<br></blockquote><blockquote type="cite"> (define (init-snips)<br></blockquote><blockquote type="cite"> (and (not (or (find-owner-snip code-editor)<br></blockquote><blockquote type="cite"> (find-owner-snip anno-editor)))<br></blockquote><blockquote type="cite"> (let ([code-snip (new stretchable-editor-snip%<br></blockquote><blockquote type="cite"> [editor code-editor]<br></blockquote><blockquote type="cite"> [with-border? #t]<br></blockquote><blockquote type="cite"> [min-width 50])]<br></blockquote><blockquote type="cite"> [anno-snip (new stretchable-editor-snip%<br></blockquote><blockquote type="cite"> [editor anno-editor]<br></blockquote><blockquote type="cite"> [with-border? #f]<br></blockquote><blockquote type="cite"> [min-width 50])])<br></blockquote><blockquote type="cite"> (make-object snip-wrapper% code-view code-snip)<br></blockquote><blockquote type="cite"> (make-object hline% code-view)<br></blockquote><blockquote type="cite"> (make-object snip-wrapper% val anno-snip)<br></blockquote><blockquote type="cite"> #t)))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (init-snips)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> ;;;;;;;;; copy+paste ;;;;;;;;;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> (define/override (copy-self)<br></blockquote><blockquote type="cite"> (let ([ed (new anno-pb%)])<br></blockquote><blockquote type="cite"> (let ([ed-code (send ed get-code-editor)]<br></blockquote><blockquote type="cite"> [ed-anno (send ed get-anno-editor)])<br></blockquote><blockquote type="cite"> (send (get-code-editor) copy-self-to ed-code)<br></blockquote><blockquote type="cite"> (send (get-anno-editor) copy-self-to ed-anno)<br></blockquote><blockquote type="cite"> ed)))<br></blockquote><blockquote type="cite"> )))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br></blockquote><blockquote type="cite">(define (test-w/text%)<br></blockquote><blockquote type="cite"> (define test-snip (new anno-snip%))<br></blockquote><blockquote type="cite"> (define test-pb (send test-snip get-editor))<br></blockquote><blockquote type="cite"> (define txt (new scheme:text%))<br></blockquote><blockquote type="cite"> (define f (mk-test-frame))<br></blockquote><blockquote type="cite"> (define c (new editor-canvas% [parent f][editor txt]))<br></blockquote><blockquote type="cite"> (send txt insert "\n(* x 3)\n4))" 0)<br></blockquote><blockquote type="cite"> (send txt insert test-snip 0)<br></blockquote><blockquote type="cite"> (send txt insert "(define (f x)\n(+ " 0)<br></blockquote><blockquote type="cite"> (send txt tabify-all)<br></blockquote><blockquote type="cite"> (send f show #t)<br></blockquote><blockquote type="cite"> )<br></blockquote><blockquote type="cite">(define (mk-test-frame)<br></blockquote><blockquote type="cite"> (new frame% [label "ah"] [width 500] [height 300]<br></blockquote><blockquote type="cite"> [alignment '(center center)]))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_________________________________________________<br></blockquote><blockquote type="cite"> For list-related administrative tasks:<br></blockquote><blockquote type="cite"> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><br></div></div></body></html>