]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: ensuring that autodoc works for qualified word references (eg unix.ffi:accept)
authorBjörn Lindqvist <bjourne@gmail.com>
Sat, 7 Jan 2017 14:20:13 +0000 (15:20 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Sat, 7 Jan 2017 14:26:19 +0000 (15:26 +0100)
extra/fuel/eval/eval-tests.factor
extra/fuel/fuel.factor
extra/fuel/help/help.factor
misc/fuel/fuel-autodoc.el

index 5d89c2fa7e3d60e8bf7a5f7598952c20107ded0d..dded18ed88f6b79b09ec4f8e6f1d67c228b2794d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: fuel.eval io.streams.string math namespaces random.data sequences
-tools.test ;
+USING: fuel fuel.eval io.streams.string math namespaces random.data
+sequences tools.test ;
 IN: fuel.eval.tests
 
 ! Make sure prettyprint doesn't limit output.
@@ -10,3 +10,11 @@ IN: fuel.eval.tests
     1000 random-string fuel-eval-result set-global
     [ fuel-send-retort ] with-string-writer length 1000 >
 ] unit-test
+
+{
+    "(nil \"IN: kernel PRIMITIVE: dup ( x -- x x )\" \"\")\n<~FUEL~>\n"
+} [
+    [
+        V{ "\"dup\"" "fuel-word-synopsis" } "scratchpad" V{ } fuel-eval-in-context
+    ] with-string-writer
+] unit-test
index 233768530fc407def175f08ec67524ef636eabf1..0db17daf91e50c3fa20abb8f2c99e062d0230c55 100644 (file)
@@ -117,7 +117,7 @@ PRIVATE>
 
 : fuel-vocab-help ( name -- ) (fuel-vocab-help) fuel-eval-set-result ;
 
-: fuel-word-synopsis ( word usings -- ) (fuel-word-synopsis) fuel-eval-set-result ;
+: fuel-word-synopsis ( word -- ) (fuel-word-synopsis) fuel-eval-set-result ;
 
 : fuel-vocab-summary ( name -- )
     (fuel-vocab-summary) fuel-eval-set-result ;
index f06f3ee1333ccd7beee70c3b605f22194fd12e45..2020763e999ca2f421a5c138cac77336848998cf 100644 (file)
@@ -97,16 +97,13 @@ SYMBOL: describe-words
 
 PRIVATE>
 
-: (fuel-word-help) ( name -- elem )
+: (fuel-word-help) ( name -- elem/f )
     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
-        fuel-find-word [ synopsis ] [ f ] if*
-    ] with-scope ;
+: (fuel-word-synopsis) ( name -- str/f )
+    fuel-find-word [ synopsis ] [ f ] if* ;
 
 : (fuel-word-def) ( name -- str )
     fuel-find-word [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
index 2ac2926139d6336b70632eb8c4ce4356896c8bfd..e391a3d9f4f50e5fc8bbebb7af6ebe24b8ca3d36 100644 (file)
@@ -57,16 +57,16 @@ USING: form with \\[fuel-load-usings]."
   (let ((word (or word (factor-symbol-at-point)))
         (fuel-log--inhibit-p t))
     (when word
-      (let* ((usings (if fuel-autodoc-eval-using-form-p :usings t))
-             (cmd (if (factor-on-vocab)
-                      `(:fuel* (,word fuel-vocab-summary) :in t)
-                    `(:fuel* ((,word :usings fuel-word-synopsis)) t ,usings)))
-             (ret (fuel-eval--send/wait cmd fuel-autodoc--timeout))
-             (res (fuel-eval--retort-result ret)))
-        (when (and ret (not (fuel-eval--retort-error ret)) (stringp res))
-          (if fuel-autodoc-minibuffer-font-lock
-              (factor-font-lock-string res)
-            res))))))
+      (let ((cmd `(:fuel* (,word ,'fuel-word-synopsis)
+                          ,(factor-current-vocab)
+                          ,(factor-usings))))
+        (let* ((ret (fuel-eval--send/wait cmd fuel-autodoc--timeout))
+               (res (fuel-eval--retort-result ret)))
+          (if (not res)
+              (message "No synposis for '%s'" word)
+            (if fuel-autodoc-minibuffer-font-lock
+                (factor-font-lock-string res)
+              res)))))))
 
 (defvar-local fuel-autodoc--fallback-function nil)