USING: editors fry io io.encodings.utf8 io.files io.files.temp io.files.unique.private io.launcher io.pathnames kernel nested-comments prettyprint sequences strings ; IN: learn (* I've got "complicated stuff" [ dup print ] with-editor working, but was hoping to be able to genericize "ed" as a debug tool to cut down on typing and I ran into stack declaration problems I don't seem to experiment my way out of. *) : with-capture ( quot ext -- fname ) [ random-name ] dip append temp-file [ [ utf8 ] curry dip '[ _ call( -- ) ] with-file-writer ] keep ; inline : with-editor ( quot -- ) ".txt" with-capture 0 edit-location ; : with-browser ( quot -- ) ".html" with-capture [ . ] [ [ { "cmd.exe" } ] dip "/c \"" "\"" surround suffix run-detached drop ] bi ; ! intended usage: (works) ! "complicated stuff" [ dup print ] with-editor ! Problems arise with callstack: GENERIC: ed ( -- ) M: string ed ( -- ) [ print ] with-editor ; (* can't parse: Stack effect declaration is wrong inferred (( x -- x )) declared (( -- )) *) ! Problems arise with callstack: GENERIC: ed2 ( -- ) M: string ed2 ( -- ) [ dup print ] with-editor ; (* can't parse: Stack effect declaration is wrong inferred (( x -- x )) declared (( -- )) *) GENERIC: ed3 ( x -- x ) M: string ed3 ( x -- x ) [ print ] with-editor ; (* can't run: Quotation's stack effect does not match call site quot [ print ] call-site (( -- )) *)