FUEL: fallback to the all-words algorithm when search doesnt work

It's to hard to figure out the correct "in" and "usings" values for
fuel-eval-in-context when *fuel help* is looking at articles. Instead
of trying, fallback on the less precise word lookup algorith and
accept that it sometimes will lead you wrong.
db4
Björn Lindqvist 2014-04-18 02:37:56 +02:00 committed by John Benediktsson
parent 368abbe777
commit b9082ca7b1
1 changed files with 13 additions and 6 deletions

View File

@ -1,9 +1,9 @@
! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs combinators fuel.eval help help.crossref
help.markup help.topics io io.streams.string kernel make namespaces
parser prettyprint sequences summary help.vocabs
USING: accessors arrays assocs combinators combinators.short-circuit fry
fuel.eval help help.crossref help.markup help.topics io io.streams.string
kernel make namespaces parser prettyprint sequences summary help.vocabs
vocabs vocabs.loader vocabs.hierarchy vocabs.metadata vocabs.parser words see
listener sets ;
FROM: vocabs.hierarchy => child-vocabs ;
@ -11,6 +11,11 @@ IN: fuel.help
<PRIVATE
! Prefer to use search which takes the execution context into
! account. If that fails, fall back on a search of all words.
: fuel-find-word ( name -- word/f )
{ [ search ] [ '[ name>> _ = ] all-words swap find nip ] } 1|| ;
: fuel-value-str ( word -- str )
[ pprint-short ] with-string-writer ; inline
@ -88,16 +93,18 @@ SYMBOL: describe-words
PRIVATE>
: (fuel-word-help) ( name -- elem )
search [ [ auto-use? on (fuel-word-element) ] with-scope ] [ f ] if* ;
fuel-find-word [
[ auto-use? on (fuel-word-element) ] with-scope
] [ f ] if* ;
: (fuel-word-synopsis) ( word usings -- str/f )
[
[ lookup-vocab ] filter interactive-vocabs [ append ] change
search [ synopsis ] [ f ] if*
fuel-find-word [ synopsis ] [ f ] if*
] with-scope ;
: (fuel-word-def) ( name -- str )
search [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
fuel-find-word [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
: (fuel-vocab-summary) ( name -- str ) >vocab-link summary ; inline