From 9fd675a632db492958366bc85e4e99e1646691c5 Mon Sep 17 00:00:00 2001
From: "Jose A. Ortega Ruiz" <jao@gnu.org>
Date: Thu, 5 Feb 2009 10:28:57 +0100
Subject: [PATCH 1/4] FUEL: Accept '?' in prompts for word and vocabs.

---
 misc/fuel/fuel-completion.el | 33 ++++++++++++++++++++++++++-------
 misc/fuel/fuel-edit.el       |  9 +--------
 misc/fuel/fuel-help.el       |  2 +-
 misc/fuel/fuel-markup.el     |  3 ++-
 misc/fuel/fuel-scaffold.el   |  2 +-
 misc/fuel/fuel-xref.el       |  2 +-
 6 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/misc/fuel/fuel-completion.el b/misc/fuel/fuel-completion.el
index e6ec8b2dc9..165a9d9b66 100644
--- a/misc/fuel/fuel-completion.el
+++ b/misc/fuel/fuel-completion.el
@@ -18,6 +18,15 @@
 (require 'fuel-eval)
 (require 'fuel-log)
 
+
+;;; Aux:
+
+(defvar fuel-completion--minibuffer-map
+  (let ((map (make-keymap)))
+    (set-keymap-parent map minibuffer-local-completion-map)
+    (define-key map "?" 'self-insert-command)
+    map))
+
 
 ;;; Vocabs dictionary:
 
@@ -33,7 +42,8 @@
   fuel-completion--vocabs)
 
 (defun fuel-completion--read-vocab (&optional reload init-input history)
-  (let ((vocabs (fuel-completion--vocabs reload)))
+  (let ((minibuffer-local-completion-map fuel-completion--minibuffer-map)
+        (vocabs (fuel-completion--vocabs reload)))
     (completing-read "Vocab name: " vocabs nil nil init-input history)))
 
 (defsubst fuel-completion--vocab-list (prefix)
@@ -170,12 +180,21 @@ terminates a current completion."
     (cons completions partial)))
 
 (defun fuel-completion--read-word (prompt &optional default history all)
-  (completing-read prompt
-                   (if all fuel-completion--all-words-list-func
-                     fuel-completion--word-list-func)
-                   nil nil nil
-                   history
-                   (or default (fuel-syntax-symbol-at-point))))
+  (let ((minibuffer-local-completion-map fuel-completion--minibuffer-map))
+    (completing-read prompt
+                     (if all fuel-completion--all-words-list-func
+                       fuel-completion--word-list-func)
+                     nil nil nil
+                     history
+                     (or default (fuel-syntax-symbol-at-point)))))
+
+(defun fuel-completion--read-vocab (refresh)
+  (let* ((minibuffer-local-completion-map fuel-completion--minibuffer-map)
+         (vocabs (fuel-completion--vocabs refresh))
+         (prompt "Vocabulary name: "))
+    (if vocabs
+        (completing-read prompt vocabs nil nil nil fuel-edit--vocab-history)
+      (read-string prompt nil fuel-edit--vocab-history))))
 
 (defun fuel-completion--complete-symbol ()
   "Complete the symbol at point.
diff --git a/misc/fuel/fuel-edit.el b/misc/fuel/fuel-edit.el
index e5f0ffd26f..5860fb998a 100644
--- a/misc/fuel/fuel-edit.el
+++ b/misc/fuel/fuel-edit.el
@@ -57,13 +57,6 @@
     (fuel-edit--visit-file (car loc) fuel-edit-word-method)
     (goto-line (if (numberp (cadr loc)) (cadr loc) 1))))
 
-(defun fuel-edit--read-vocabulary-name (refresh)
-  (let* ((vocabs (fuel-completion--vocabs refresh))
-         (prompt "Vocabulary name: "))
-    (if vocabs
-        (completing-read prompt vocabs nil nil nil fuel-edit--vocab-history)
-      (read-string prompt nil fuel-edit--vocab-history))))
-
 (defun fuel-edit--edit-article (name)
   (let ((cmd `(:fuel* (,name fuel-get-article-location) "fuel" t)))
     (fuel-edit--try-edit (fuel-eval--send/wait cmd))))
@@ -80,7 +73,7 @@
 When called interactively, asks for vocabulary with completion.
 With prefix argument, refreshes cached vocabulary list."
   (interactive "P")
-  (let* ((vocab (or vocab (fuel-edit--read-vocabulary-name refresh)))
+  (let* ((vocab (or vocab (fuel-completion--read-vocab refresh)))
          (cmd `(:fuel* (,vocab fuel-get-vocab-location) "fuel" t)))
     (fuel-edit--try-edit (fuel-eval--send/wait cmd))))
 
diff --git a/misc/fuel/fuel-help.el b/misc/fuel/fuel-help.el
index a82de388da..cfc8cab7f1 100644
--- a/misc/fuel/fuel-help.el
+++ b/misc/fuel/fuel-help.el
@@ -257,7 +257,7 @@ buffer."
 
 (defun fuel-help-vocab (vocab)
   "Ask for a vocabulary name and show its help page."
-  (interactive (list (fuel-edit--read-vocabulary-name nil)))
+  (interactive (list (fuel-completion--read-vocab nil)))
   (fuel-help--get-vocab vocab))
 
 (defun fuel-help-next (&optional forget-current)
diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el
index 4844233ae7..980ea111a6 100644
--- a/misc/fuel/fuel-markup.el
+++ b/misc/fuel/fuel-markup.el
@@ -282,7 +282,8 @@
   (fuel-markup--insert-newline)
   (dolist (s (cdr e))
     (fuel-markup--snippet (list '$snippet s))
-    (newline)))
+    (newline))
+  (newline))
 
 (defun fuel-markup--markup-example (e)
   (fuel-markup--insert-newline)
diff --git a/misc/fuel/fuel-scaffold.el b/misc/fuel/fuel-scaffold.el
index 05d825593c..ac400c5622 100644
--- a/misc/fuel/fuel-scaffold.el
+++ b/misc/fuel/fuel-scaffold.el
@@ -71,7 +71,7 @@ You can configure `fuel-scaffold-developer-name' (set by default to
 `user-full-name') for the name to be inserted in the generated file."
   (interactive "P")
   (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
-                   (fuel-edit--read-vocabulary-name nil)))
+                    (fuel-completion--read-vocab nil)))
          (cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-help)
                        "fuel"))
          (ret (fuel-eval--send/wait cmd))
diff --git a/misc/fuel/fuel-xref.el b/misc/fuel/fuel-xref.el
index 4d444ebe3e..faf1897304 100644
--- a/misc/fuel/fuel-xref.el
+++ b/misc/fuel/fuel-xref.el
@@ -244,7 +244,7 @@ With prefix argument, force reload of vocabulary list."
 With prefix argument, ask for the vocab."
   (interactive "P")
   (let ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
-                   (fuel-edit--read-vocabulary-name))))
+                   (fuel-completion--read-vocab nil))))
     (when vocab
       (fuel-xref--show-vocab-words vocab
                                    (fuel-syntax--file-has-private)))))

From 84846e21d840c7d6cc74db4d6e04c1062c640baf Mon Sep 17 00:00:00 2001
From: "Jose A. Ortega Ruiz" <jao@gnu.org>
Date: Thu, 5 Feb 2009 10:45:44 +0100
Subject: [PATCH 2/4] FUEL: Small nits.

---
 misc/fuel/fuel-completion.el | 12 +++++++-----
 misc/fuel/fuel-edit.el       |  1 -
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/misc/fuel/fuel-completion.el b/misc/fuel/fuel-completion.el
index 165a9d9b66..c21d25901f 100644
--- a/misc/fuel/fuel-completion.el
+++ b/misc/fuel/fuel-completion.el
@@ -188,13 +188,15 @@ terminates a current completion."
                      history
                      (or default (fuel-syntax-symbol-at-point)))))
 
+(defvar fuel-completion--vocab-history nil)
+
 (defun fuel-completion--read-vocab (refresh)
-  (let* ((minibuffer-local-completion-map fuel-completion--minibuffer-map)
-         (vocabs (fuel-completion--vocabs refresh))
-         (prompt "Vocabulary name: "))
+  (let ((minibuffer-local-completion-map fuel-completion--minibuffer-map)
+        (vocabs (fuel-completion--vocabs refresh))
+        (prompt "Vocabulary name: "))
     (if vocabs
-        (completing-read prompt vocabs nil nil nil fuel-edit--vocab-history)
-      (read-string prompt nil fuel-edit--vocab-history))))
+        (completing-read prompt vocabs nil nil nil fuel-completion--vocab-history)
+      (read-string prompt nil fuel-completion--vocab-history))))
 
 (defun fuel-completion--complete-symbol ()
   "Complete the symbol at point.
diff --git a/misc/fuel/fuel-edit.el b/misc/fuel/fuel-edit.el
index 5860fb998a..941f57140e 100644
--- a/misc/fuel/fuel-edit.el
+++ b/misc/fuel/fuel-edit.el
@@ -65,7 +65,6 @@
 ;;; Editing commands:
 
 (defvar fuel-edit--word-history nil)
-(defvar fuel-edit--vocab-history nil)
 (defvar fuel-edit--previous-location nil)
 
 (defun fuel-edit-vocabulary (&optional refresh vocab)

From 08ad6ca1162f54d7264d95dc02740405b4c332c2 Mon Sep 17 00:00:00 2001
From: "Jose A. Ortega Ruiz" <jao@gnu.org>
Date: Sun, 8 Feb 2009 23:22:23 +0100
Subject: [PATCH 3/4] FUEL: use factor.com instead of factor.exe as default
 binary under Windows.

---
 misc/fuel/fuel-connection.el | 8 ++++++--
 misc/fuel/fuel-listener.el   | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/misc/fuel/fuel-connection.el b/misc/fuel/fuel-connection.el
index 14c4d0b36f..f180d0f2b4 100644
--- a/misc/fuel/fuel-connection.el
+++ b/misc/fuel/fuel-connection.el
@@ -144,8 +144,12 @@
   (add-hook 'comint-redirect-hook
             'fuel-con--comint-redirect-hook nil t))
 
-(defadvice comint-redirect-setup (after fuel-con--advice activate)
-  (setq comint-redirect-finished-regexp fuel-con--comint-finished-regex))
+(defadvice comint-redirect-setup
+  (after fuel-con--advice (output-buffer comint-buffer finished-regexp &optional echo))
+  (with-current-buffer comint-buffer
+    (when fuel-con--connection
+      (setq comint-redirect-finished-regexp fuel-con--comint-finished-regex))))
+(ad-activate 'comint-redirect-setup)
 
 (defun fuel-con--comint-preoutput-filter (str)
   (when (string-match fuel-con--comint-finished-regex str)
diff --git a/misc/fuel/fuel-listener.el b/misc/fuel/fuel-listener.el
index d0898de04f..b8bf4d4b7f 100644
--- a/misc/fuel/fuel-listener.el
+++ b/misc/fuel/fuel-listener.el
@@ -32,7 +32,7 @@
 
 (defcustom fuel-listener-factor-binary
   (expand-file-name (cond ((eq system-type 'windows-nt)
-                           "factor.exe")
+                           "factor.com")
                           ((eq system-type 'darwin)
                            "Factor.app/Contents/MacOS/factor")
                           (t "factor"))

From 25d20c6000d36dc0d04c52ad5b2998bb23a1af2b Mon Sep 17 00:00:00 2001
From: Nicholas Seckar <nseckar@gmail.com>
Date: Sun, 8 Feb 2009 23:45:59 -0800
Subject: [PATCH 4/4] Update docs for GENERIC: GENERIC# and HOOK to show stack
 effect decl

---
 core/syntax/syntax-docs.factor | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor
index e08821bddd..035622454f 100644
--- a/core/syntax/syntax-docs.factor
+++ b/core/syntax/syntax-docs.factor
@@ -551,12 +551,12 @@ HELP: BIN:
 { $examples { $example "USE: prettyprint" "BIN: 100 ." "4" } } ;
 
 HELP: GENERIC:
-{ $syntax "GENERIC: word" }
+{ $syntax "GENERIC: word" "GENERIC: word ( stack -- effect )" }
 { $values { "word" "a new word to define" } }
 { $description "Defines a new generic word in the current vocabulary. Initially, it contains no methods, and thus will throw a " { $link no-method } " error when called." } ;
 
 HELP: GENERIC#
-{ $syntax "GENERIC# word n" }
+{ $syntax "GENERIC# word n" "GENERIC# word n ( stack -- effect )" }
 { $values { "word" "a new word to define" } { "n" "the stack position to dispatch on" } }
 { $description "Defines a new generic word which dispatches on the " { $snippet "n" } "th most element from the top of the stack in the current vocabulary. Initially, it contains no methods, and thus will throw a " { $link no-method } " error when called." }
 { $notes
@@ -571,7 +571,7 @@ HELP: MATH:
 { $description "Defines a new generic word which uses the " { $link math-combination } " method combination." } ;
 
 HELP: HOOK:
-{ $syntax "HOOK: word variable" }
+{ $syntax "HOOK: word variable" "HOOK: word variable ( stack -- effect ) " }
 { $values { "word" "a new word to define" } { "variable" word } }
 { $description "Defines a new hook word in the current vocabulary. Hook words are generic words which dispatch on the value of a variable, so methods are defined with " { $link POSTPONE: M: } ". Hook words differ from other generic words in that the dispatch value is removed from the stack before the chosen method is called." }
 { $examples