]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/fuel/fuel.factor
FUEL: improved fuel-get-uses
[factor.git] / extra / fuel / fuel.factor
index a7a1cc81d50519a4f0e6583cb6c675749cc773cd..81b0022dc1792831ec68db92110e81f68fd4c113 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs compiler.units continuations fuel.eval
+USING: accessors assocs compiler.units continuations fry fuel.eval
 fuel.help fuel.xref help.topics io.pathnames kernel namespaces parser
-parser.notes sequences tools.scaffold vocabs vocabs.files
+parser.notes sequences source-files tools.scaffold vocabs vocabs.files
 vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.parser words ;
 IN: fuel
 
@@ -20,7 +20,7 @@ IN: fuel
 : fuel-eval-set-result ( obj -- )
     clone eval-result set-global ; inline
 
-: fuel-retort ( -- ) send-retort ; inline
+: fuel-retort ( -- ) f f "" send-retort ; inline
 
 ! Loading files
 
@@ -29,31 +29,25 @@ IN: fuel
 SYMBOL: :uses
 SYMBOL: :uses-suggestions
 
-: is-use-restart ( restart -- ? )
+: is-use-restart? ( restart -- ? )
     name>> [ "Use the " head? ] [ " vocabulary" tail? ] bi and ;
 
 : get-restart-vocab ( restart -- vocab/f )
     obj>> dup word? [ vocabulary>> ] [ drop f ] if ;
 
-: is-suggested-restart ( restart -- ? )
-    dup is-use-restart [
+: 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
+    restarts get [ is-suggested-restart? ] filter
     dup length 1 = [ first continue-restart ] [ drop ] if ;
 
 : set-use-hook ( -- )
     [ manifest get auto-used>> clone :uses prefix fuel-eval-set-result ]
     print-use-hook set ;
 
-: get-uses ( lines -- )
-    [
-        parser-quiet? on
-        parse-fresh drop
-    ] curry with-compilation-unit ; inline
-
 PRIVATE>
 
 : fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b ) -- ..b )
@@ -61,13 +55,20 @@ PRIVATE>
     [ try-suggested-restarts rethrow ] recover ; inline
 
 : fuel-run-file ( path -- )
-    [ set-use-hook run-file ] curry with-scope ; inline
+    '[ _ set-use-hook run-file ] with-scope ; inline
 
 : fuel-with-autouse ( ..a quot: ( ..a -- ..b ) -- ..b )
-    [ set-use-hook call ] curry with-scope ; inline
-
-: fuel-get-uses ( lines -- )
-    [ get-uses ] curry fuel-with-autouse ;
+    '[ _ set-use-hook call ] with-scope ; inline
+
+: fuel-get-uses ( name lines -- )
+    '[
+        [
+            _ [
+                parser-quiet? on
+                _ parse-fresh drop
+            ] with-source-file
+        ] with-compilation-unit
+    ] fuel-with-autouse ;
 
 ! Edit locations
 
@@ -108,7 +109,7 @@ PRIVATE>
 
 ! Help support
 
-: fuel-get-article ( name -- ) lookup-article fuel-eval-set-result ;
+: fuel-get-article ( name -- ) fuel.help:get-article fuel-eval-set-result ;
 
 : fuel-get-article-title ( name -- )
     articles get at [ article-title ] [ f ] if* fuel-eval-set-result ;