! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
! 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
parser prettyprint sequences summary help.vocabs
-vocabs vocabs.loader vocabs.hierarchy vocabs.metadata words see
-listener ;
+vocabs vocabs.loader vocabs.hierarchy vocabs.metadata vocabs.parser words see
+listener sets ;
FROM: vocabs.hierarchy => child-vocabs ;
IN: fuel.help
<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 )
[ pprint-short ] with-string-writer ; inline
PRIVATE>
: (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 )
[
[ lookup-vocab ] filter interactive-vocabs [ append ] change
- fuel-find-word [ synopsis ] [ f ] if*
+ search [ synopsis ] [ f ] if*
] with-scope ;
: (fuel-word-see) ( word -- elem )
[ [ see ] with-string-writer \ $code swap 2array ] bi 3array ; inline
: (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
\f
;;; 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 ()
(funcall factor-current-vocab-function))
(when (re-search-backward factor-current-vocab-regex nil t)
(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)
(defsubst factor-usings ()
(let ((def (or word (fuel-help--read-word see))))
(when def
(let ((cmd `(:fuel* (,def ,(if see 'fuel-word-see 'fuel-word-help))
- "fuel" t)))
+ ,(factor-current-vocab) t)))
(when print-message
(message "Looking up '%s' ..." def))
(let* ((ret (fuel-eval--send/wait cmd))