]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/fuel/fuel.factor
FUEL: improved fuel-get-uses
[factor.git] / extra / fuel / fuel.factor
index d1383311f9fe9f49717aee827aaa0bc67009b75a..81b0022dc1792831ec68db92110e81f68fd4c113 100644 (file)
@@ -1,9 +1,9 @@
 ! 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
-sequences tools.scaffold vocabs vocabs.files vocabs.hierarchy
-vocabs.loader vocabs.metadata vocabs.parser words ;
+parser.notes sequences source-files tools.scaffold vocabs vocabs.files
+vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.parser words ;
 IN: fuel
 
 ! Evaluation
@@ -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,28 +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 ;
 
-: fuel-set-use-hook ( -- )
+: set-use-hook ( -- )
     [ manifest get auto-used>> clone :uses prefix fuel-eval-set-result ]
     print-use-hook set ;
 
-: (fuel-get-uses) ( lines -- )
-    [ parse-fresh drop ] curry with-compilation-unit ; inline
-
 PRIVATE>
 
 : fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b ) -- ..b )
@@ -58,13 +55,20 @@ PRIVATE>
     [ try-suggested-restarts rethrow ] recover ; inline
 
 : fuel-run-file ( path -- )
-    [ fuel-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 )
-    [ auto-use? on fuel-set-use-hook call ] curry with-scope ; inline
-
-: fuel-get-uses ( lines -- )
-    [ (fuel-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
 
@@ -105,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 ;
@@ -131,35 +135,44 @@ PRIVATE>
 
 ! Scaffold support
 
-: fuel-scaffold-name ( devname -- )
+: scaffold-name ( devname -- )
     [ developer-name set ] when* ;
 
 : fuel-scaffold-vocab ( root name devname -- )
-    [ fuel-scaffold-name dup [ scaffold-vocab ] dip ] with-scope
+    [ scaffold-name dup [ scaffold-vocab ] dip ] with-scope
     dup require vocab-source-path absolute-path fuel-eval-set-result ;
 
 : fuel-scaffold-help ( name devname -- )
-    [ fuel-scaffold-name dup require dup scaffold-docs ] with-scope
+    [ scaffold-name dup require dup scaffold-docs ] with-scope
     vocab-docs-path absolute-path fuel-eval-set-result ;
 
 : fuel-scaffold-tests ( name devname -- )
-    [ fuel-scaffold-name dup require dup scaffold-tests ] with-scope
+    [ scaffold-name dup require dup scaffold-tests ] with-scope
     vocab-tests-file absolute-path fuel-eval-set-result ;
 
 : fuel-scaffold-authors ( name devname -- )
-    [ fuel-scaffold-name dup require dup scaffold-authors ] with-scope
+    [ scaffold-name dup require dup scaffold-authors ] with-scope
     [ vocab-authors-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ;
 
 : fuel-scaffold-tags ( name tags -- )
     [ scaffold-tags ]
-    [ drop [ vocab-tags-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ;
+    [
+        drop [ vocab-tags-path ] keep swap
+        vocab-append-path absolute-path fuel-eval-set-result
+    ] 2bi ;
 
 : fuel-scaffold-summary ( name summary -- )
     [ scaffold-summary ]
-    [ drop [ vocab-summary-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ;
+    [
+        drop [ vocab-summary-path ] keep swap
+        vocab-append-path absolute-path fuel-eval-set-result
+    ] 2bi ;
 
 : fuel-scaffold-platforms ( name platforms -- )
     [ scaffold-platforms ]
-    [ drop [ vocab-platforms-path ] keep swap vocab-append-path absolute-path fuel-eval-set-result ] 2bi ;
+    [
+        drop [ vocab-platforms-path ] keep swap
+        vocab-append-path absolute-path fuel-eval-set-result
+    ] 2bi ;
 
 : fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ;