FUEL: correct fuel-helps word lookup algorithm
e.g if you lookup help for pop you should see the help page for sequences:pop not persistent.deques.private:popdb4
parent
792ed03b4d
commit
35fd1ad8cb
|
@ -1,20 +1,16 @@
|
||||||
! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
|
! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
|
||||||
USING: accessors arrays assocs combinators help help.crossref
|
USING: accessors arrays assocs combinators fuel.eval help help.crossref
|
||||||
help.markup help.topics io io.streams.string kernel make namespaces
|
help.markup help.topics io io.streams.string kernel make namespaces
|
||||||
parser prettyprint sequences summary help.vocabs
|
parser prettyprint sequences summary help.vocabs
|
||||||
vocabs vocabs.loader vocabs.hierarchy vocabs.metadata words see
|
vocabs vocabs.loader vocabs.hierarchy vocabs.metadata vocabs.parser words see
|
||||||
listener ;
|
listener sets ;
|
||||||
FROM: vocabs.hierarchy => child-vocabs ;
|
FROM: vocabs.hierarchy => child-vocabs ;
|
||||||
IN: fuel.help
|
IN: fuel.help
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: fuel-find-word ( name -- word/f )
|
|
||||||
[ [ name>> ] dip = ] curry all-words swap filter
|
|
||||||
dup empty? not [ first ] [ drop f ] if ;
|
|
||||||
|
|
||||||
: fuel-value-str ( word -- str )
|
: fuel-value-str ( word -- str )
|
||||||
[ pprint-short ] with-string-writer ; inline
|
[ pprint-short ] with-string-writer ; inline
|
||||||
|
|
||||||
|
@ -92,12 +88,12 @@ SYMBOL: describe-words
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: (fuel-word-help) ( name -- elem )
|
: (fuel-word-help) ( name -- elem )
|
||||||
fuel-find-word [ [ auto-use? on (fuel-word-element) ] with-scope ] [ f ] if* ;
|
search [ [ auto-use? on (fuel-word-element) ] with-scope ] [ f ] if* ;
|
||||||
|
|
||||||
: (fuel-word-synopsis) ( word usings -- str/f )
|
: (fuel-word-synopsis) ( word usings -- str/f )
|
||||||
[
|
[
|
||||||
[ lookup-vocab ] filter interactive-vocabs [ append ] change
|
[ lookup-vocab ] filter interactive-vocabs [ append ] change
|
||||||
fuel-find-word [ synopsis ] [ f ] if*
|
search [ synopsis ] [ f ] if*
|
||||||
] with-scope ;
|
] with-scope ;
|
||||||
|
|
||||||
: (fuel-word-see) ( word -- elem )
|
: (fuel-word-see) ( word -- elem )
|
||||||
|
@ -105,7 +101,7 @@ PRIVATE>
|
||||||
[ [ see ] with-string-writer \ $code swap 2array ] bi 3array ; inline
|
[ [ see ] with-string-writer \ $code swap 2array ] bi 3array ; inline
|
||||||
|
|
||||||
: (fuel-word-def) ( name -- str )
|
: (fuel-word-def) ( name -- str )
|
||||||
fuel-find-word [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
|
search [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
|
||||||
|
|
||||||
: (fuel-vocab-summary) ( name -- str ) >vocab-link summary ; inline
|
: (fuel-vocab-summary) ( name -- str ) >vocab-link summary ; inline
|
||||||
|
|
||||||
|
|
|
@ -662,7 +662,7 @@ source/docs/tests file. When set to false, you'll be asked only once."
|
||||||
|
|
||||||
;;; USING/IN:
|
;;; USING/IN:
|
||||||
|
|
||||||
(defvar-local factor-current-vocab-function 'factor-find-in)
|
(defvar-local factor-current-vocab-function 'factor-find-vocab-name)
|
||||||
|
|
||||||
(defsubst factor-current-vocab ()
|
(defsubst factor-current-vocab ()
|
||||||
(funcall factor-current-vocab-function))
|
(funcall factor-current-vocab-function))
|
||||||
|
@ -672,6 +672,16 @@ source/docs/tests file. When set to false, you'll be asked only once."
|
||||||
(when (re-search-backward factor-current-vocab-regex nil t)
|
(when (re-search-backward factor-current-vocab-regex nil t)
|
||||||
(match-string-no-properties 1))))
|
(match-string-no-properties 1))))
|
||||||
|
|
||||||
|
(defun factor-in-private? ()
|
||||||
|
"t if point is withing a PRIVATE-block, nil otherwise."
|
||||||
|
(save-excursion
|
||||||
|
(when (re-search-backward "\\_<<?PRIVATE>?\\_>" nil t)
|
||||||
|
(string= (match-string-no-properties 0) "<PRIVATE"))))
|
||||||
|
|
||||||
|
(defun factor-find-vocab-name ()
|
||||||
|
"name of the vocab with possible .private suffix"
|
||||||
|
(concat (factor-find-in) (if (factor-in-private?) ".private" "")))
|
||||||
|
|
||||||
(defvar-local factor-usings-function 'factor-find-usings)
|
(defvar-local factor-usings-function 'factor-find-usings)
|
||||||
|
|
||||||
(defsubst factor-usings ()
|
(defsubst factor-usings ()
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
(let ((def (or word (fuel-help--read-word see))))
|
(let ((def (or word (fuel-help--read-word see))))
|
||||||
(when def
|
(when def
|
||||||
(let ((cmd `(:fuel* (,def ,(if see 'fuel-word-see 'fuel-word-help))
|
(let ((cmd `(:fuel* (,def ,(if see 'fuel-word-see 'fuel-word-help))
|
||||||
"fuel" t)))
|
,(factor-current-vocab) t)))
|
||||||
(when print-message
|
(when print-message
|
||||||
(message "Looking up '%s' ..." def))
|
(message "Looking up '%s' ..." def))
|
||||||
(let* ((ret (fuel-eval--send/wait cmd))
|
(let* ((ret (fuel-eval--send/wait cmd))
|
||||||
|
|
Loading…
Reference in New Issue