]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: Don't load vocabs in USING: form by default.
authorJose A. Ortega Ruiz <jao@gnu.org>
Thu, 19 Feb 2009 00:33:47 +0000 (01:33 +0100)
committerJose A. Ortega Ruiz <jao@gnu.org>
Thu, 19 Feb 2009 00:33:47 +0000 (01:33 +0100)
extra/fuel/fuel.factor
extra/fuel/help/help.factor
misc/fuel/README
misc/fuel/fuel-autodoc.el
misc/fuel/fuel-eval.el
misc/fuel/fuel-mode.el

index 2bf8f1b98d36df37ec124185f2a1592b7c68412e..403708e880884ced3fda8304b37edbc4356312d5 100644 (file)
@@ -99,6 +99,8 @@ 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-vocab-summary ( name -- )
     (fuel-vocab-summary) fuel-eval-set-result ;
 
index 55183734b37ce14132a385b568cb8e2f3f4c7dd2..bf637fd0b32dc0e4f90b8c4e01958b931c4dc321 100644 (file)
@@ -90,6 +90,12 @@ PRIVATE>
 : (fuel-word-help) ( name -- elem )
     fuel-find-word [ [ auto-use? on (fuel-word-element) ] with-scope ] [ f ] if* ;
 
+: (fuel-word-synopsis) ( word usings -- str/f )
+    [
+        [ vocab ] filter interactive-vocabs get append interactive-vocabs set
+        fuel-find-word [ synopsis ] when*
+    ] with-scope ;
+
 : (fuel-word-see) ( word -- elem )
     [ name>> \ article swap ]
     [ [ see ] with-string-writer \ $code swap 2array ] bi 3array ; inline
index d712560b03b6384804e5101f25fb9a4a3a658a5d..79b8f49f9af67e9aa5fd6ce73b17c327d227f90b 100644 (file)
@@ -111,6 +111,7 @@ beast.
     | C-cC-ev         | edit vocabulary (fuel-edit-vocabulary)                     |
     | C-cC-ew         | edit word (fuel-edit-word-at-point)                        |
     | C-cC-ed         | edit word's doc (C-u M-x fuel-edit-word-doc-at-point)      |
+    | C-cC-el         | load vocabs in USING: form                                 |
     |-----------------+------------------------------------------------------------|
     | C-cC-er         | eval region                                                |
     | C-M-r, C-cC-ee  | eval region, extending it to definition boundaries         |
index 76919702bb93386ed35a26cb2c64c346878144b5..d02e4fcfb95e5f553d3c9419d9940ca9fd3aed35 100644 (file)
   :type 'boolean)
 
 
+(defcustom fuel-autodoc-eval-using-form-p nil
+  "When enabled, automatically load vocabularies in USING: form
+to display autodoc messages.
+
+In order to show autodoc messages for words in a Factor buffer,
+the used vocabularies must be loaded in the Factor image. Setting
+this variable to `t' will do that automatically for you,
+asynchronously. That means that you'll be able to move around
+while the vocabs are being loaded, but no other FUEL
+functionality will be available until loading finishes (and it
+may take a while). Thus, this functionality is disabled by
+default. You can force loading the vocabs in a Factor buffer
+USING: form with \\[fuel-load-usings]."
+  :group 'fuel-autodoc
+  :type 'boolean)
+
 \f
 ;;; Eldoc function:
 
   (let ((word (or word (fuel-syntax-symbol-at-point)))
         (fuel-log--inhibit-p t))
     (when word
-      (let* ((cmd (if (fuel-syntax--in-using)
+      (let* ((usings (if fuel-autodoc-eval-using-form-p :usings t))
+             (cmd (if (fuel-syntax--in-using)
                       `(:fuel* (,word fuel-vocab-summary) :in t)
-                    `(:fuel* (((:quote ,word) synopsis :get)) :in)))
+                    `(: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))
index 9e8210a3e3e89983672704752e8fc1952f4d83c4..985722854f52e6fc75e93ecafe810288307fd120 100644 (file)
@@ -77,7 +77,7 @@
         (t (error "Invalid 'in' (%s)" in))))
 
 (defsubst factor--fuel-usings (usings)
-  (cond ((null usings) :usings)
+  (cond ((or (null usings) (eq usings :usings)) :usings)
         ((eq usings t) nil)
         ((listp usings) `(:array ,@usings))
         (t (error "Invalid 'usings' (%s)" usings))))
index 504308fccd5998e3b1e4bec9bf34c08e461c0e47..c4f08f3c6205f40cfefb064940ba2c003dc6d45d 100644 (file)
@@ -132,6 +132,18 @@ With prefix argument, ask for the file name."
   (let ((file (car (fuel-mode--read-file arg))))
     (when file (fuel-debug--uses-for-file file))))
 
+(defun fuel-load-usings ()
+  "Loads all vocabularies in the current buffer's USING: from.
+Useful to activate autodoc help messages in a vocabulary not yet
+loaded. See documentation for `fuel-autodoc-eval-using-form-p'
+for details."
+  (interactive)
+  (message "Loading all vocabularies in USING: form ...")
+  (let ((err (fuel-eval--retort-error
+              (fuel-eval--send/wait '(:fuel* (t) t :usings) 120000))))
+    (message (if err "Warning: some vocabularies failed to load"
+               "All vocabularies loaded"))))
+
 \f
 ;;; Minor mode definition:
 
@@ -191,7 +203,8 @@ interacting with a factor listener is at your disposal.
 
 (fuel-mode--key ?e ?d 'fuel-edit-word-doc-at-point)
 (fuel-mode--key ?e ?e 'fuel-eval-extended-region)
-(fuel-mode--key ?e ?l 'fuel-run-file)
+(fuel-mode--key ?e ?k 'fuel-run-file)
+(fuel-mode--key ?e ?l 'fuel-load-usings)
 (fuel-mode--key ?e ?r 'fuel-eval-region)
 (fuel-mode--key ?e ?u 'fuel-update-usings)
 (fuel-mode--key ?e ?v 'fuel-edit-vocabulary)