]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'autouse-existing-usings' of git@github.com:seckar/factor into cleaner...
authorNicholas Seckar <nseckar@gmail.com>
Sun, 19 Apr 2009 21:31:44 +0000 (14:31 -0700)
committerNicholas Seckar <nseckar@gmail.com>
Sun, 19 Apr 2009 21:31:44 +0000 (14:31 -0700)
1  2 
extra/fuel/fuel.factor

diff --combined extra/fuel/fuel.factor
index 413aefdc761e62d69b9a2a6c6db89a8f4370eb08,a8c2adc3e1a3ccc8b10f58ed308c99163fe3ad77..3c623212b05ade78108f04231ffff39c61adfc09
@@@ -1,9 -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
  
  <PRIVATE
  
  SYMBOL: :uses
+ SYMBOL: :uses-suggestions
+ : is-use-restart ( restart -- ? )
+     name>> [ "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 ]
  
  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
  
  : fuel-vocab-summary ( name -- )
      (fuel-vocab-summary) fuel-eval-set-result ;
  
 -: fuel-index ( quot -- ) call format-index fuel-eval-set-result ;
 +: fuel-index ( quot -- ) call( -- seq ) format-index fuel-eval-set-result ;
  
  : fuel-get-vocabs/tag ( tag -- )
      (fuel-get-vocabs/tag) fuel-eval-set-result ;