]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: correct fuel-helps word lookup algorithm
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 13 Apr 2014 14:34:47 +0000 (16:34 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 14 Apr 2014 15:38:33 +0000 (08:38 -0700)
e.g if you lookup help for pop you should see the help page for
sequences:pop not persistent.deques.private:pop

extra/fuel/help/help.factor
misc/fuel/factor-mode.el
misc/fuel/fuel-help.el

index 23387726859b9b354cc89c655a2e887e237f33ae..b540b0ef5d8c7e5868b19e406026f4100ffcf998 100644 (file)
@@ -1,20 +1,16 @@
 ! 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
 
@@ -92,12 +88,12 @@ SYMBOL: describe-words
 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 )
@@ -105,7 +101,7 @@ PRIVATE>
     [ [ 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
 
index d46253b92088337b14c3afade98d5619dd055168..ecee2dc14bdd03b7fd8a690c6768c95c5f0c755a 100644 (file)
@@ -662,7 +662,7 @@ source/docs/tests file. When set to false, you'll be asked only once."
 \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))
@@ -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)
       (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 ()
index 68f6db1ab3695a41a69bb270f6eae3026c43af81..daf429b70332fb57023cd81094ff4b946e02fc4d 100644 (file)
   (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))