X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=extra%2Ffuel%2Ffuel.factor;h=3c623212b05ade78108f04231ffff39c61adfc09;hp=413aefdc761e62d69b9a2a6c6db89a8f4370eb08;hb=86a6b75160f0d3d0a103b9dd65bb28350bc857e3;hpb=3148429e0c44a4b71bb5985adfb770bb40d530f5 diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 413aefdc76..3c623212b0 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs compiler.units fuel.eval fuel.help fuel.remote fuel.xref -help.topics io.pathnames kernel namespaces parser sequences -tools.scaffold vocabs.loader ; +USING: accessors assocs compiler.units continuations fuel.eval fuel.help +fuel.remote fuel.xref help.topics io.pathnames kernel math namespaces parser +sequences tools.scaffold vocabs.loader ; IN: fuel @@ -28,6 +28,24 @@ IN: fuel > [ "Use the " head? ] [ " vocabulary" tail? ] bi and ; + +: get-restart-vocab ( restart -- vocab ) + [ "Use the " length ] dip + name>> [ length " vocabulary" length - ] keep + subseq ; + +: is-suggested-restart ( restart -- ? ) + dup is-use-restart [ + get-restart-vocab :uses-suggestions get member? + ] [ drop f ] if ; + +: try-suggested-restarts ( -- ) + restarts get [ is-suggested-restart ] filter + dup length 1 = [ first restart ] [ drop ] if ; : fuel-set-use-hook ( -- ) [ amended-use get clone :uses prefix fuel-eval-set-result ] @@ -38,6 +56,10 @@ SYMBOL: :uses PRIVATE> +: fuel-use-suggested-vocabs ( ... suggestions quot: ( ... -- ... ) -- ... ) + [ :uses-suggestions set ] dip + [ try-suggested-restarts rethrow ] recover ; + : fuel-run-file ( path -- ) [ fuel-set-use-hook run-file ] curry with-scope ; inline