]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: M-. completes vocab names when in USING: stanza.
authorJose A. Ortega Ruiz <jao@gnu.org>
Wed, 17 Dec 2008 23:49:01 +0000 (00:49 +0100)
committerJose A. Ortega Ruiz <jao@gnu.org>
Wed, 17 Dec 2008 23:49:01 +0000 (00:49 +0100)
extra/fuel/fuel.factor
misc/fuel/fuel-completion.el
misc/fuel/fuel-connection.el
misc/fuel/fuel-syntax.el

index 15b9adf87015b95353f508eb54188e5b95eeb77b..dacf57cc7fa679a9dd5bff4a14dcc94b595f3841 100644 (file)
@@ -160,6 +160,8 @@ M: source-file fuel-pprint path>> fuel-pprint ;
 
 : fuel-end-eval ( -- ) [ ] (fuel-end-eval) ; inline
 
+! Edit locations
+
 : fuel-get-edit-location ( defspec -- )
     where [
        first2 [ (normalize-path) ] dip 2array fuel-eval-set-result
@@ -193,7 +195,7 @@ MEMO: (fuel-vocab-words) ( name -- seq )
 
 : (fuel-get-words) ( prefix names/f -- seq )
     [ fuel-vocabs-words ] [ fuel-current-words ] if* natural-sort
-    swap  fuel-filter-prefix ;
+    swap fuel-filter-prefix ;
 
 : fuel-get-words ( prefix names -- )
     (fuel-get-words) fuel-eval-set-result ; inline
index a4f467fd98939a86177af74dcb724255d1c0f654..c7340c7037eccb76a6c9e35734a431082b334bb0 100644 (file)
              (fuel-eval--send/wait '(:fuel* (fuel-get-vocabs) "fuel" (:array)))))))
   fuel-completion--vocabs)
 
+(defsubst fuel-completion--vocab-list (prefix)
+  (fuel-eval--retort-result
+   (fuel-eval--send/wait `(:fuel* (,prefix fuel-get-vocabs/prefix) t t))))
+
 (defun fuel-completion--words (prefix vocabs)
   (let ((vs (if vocabs (cons :array vocabs) 'f))
         (us (or vocabs 't)))
@@ -152,8 +156,10 @@ terminates a current completion."
 (defvar fuel-completion--all-words-list-func
   (completion-table-dynamic 'fuel-completion--all-words-list))
 
-(defun fuel-completion--complete (prefix)
-  (let* ((words (fuel-completion--word-list prefix))
+(defun fuel-completion--complete (prefix vocabs)
+  (let* ((words (if vocabs
+                    (fuel-completion--vocabs)
+                    (fuel-completion--word-list prefix)))
          (completions (all-completions prefix words))
          (partial (try-completion prefix words))
          (partial (if (eq partial t) prefix partial)))
@@ -174,7 +180,7 @@ Perform completion similar to Emacs' complete-symbol."
   (let* ((end (point))
          (beg (fuel-syntax--symbol-start))
          (prefix (buffer-substring-no-properties beg end))
-         (result (fuel-completion--complete prefix))
+         (result (fuel-completion--complete prefix (fuel-syntax--in-using)))
          (completions (car result))
          (partial (cdr result)))
     (cond ((null completions)
index 641e1833b9ea91f08bef91c2d74d0084c473482e..3cac40bd1630d2ef6869322b692ddaf9d76141f0 100644 (file)
@@ -46,8 +46,7 @@
         (cons :id (random))
         (cons :string str)
         (cons :continuation cont)
-        (cons :buffer (or sender-buffer (current-buffer)))
-        (cons :output "")))
+        (cons :buffer (or sender-buffer (current-buffer)))))
 
 (defsubst fuel-con--request-p (req)
   (and (listp req) (eq (car req) :fuel-connection-request)))
 (defsubst fuel-con--request-buffer (req)
   (cdr (assoc :buffer req)))
 
-(defun fuel-con--request-output (req &optional suffix)
-  (let ((cell (assoc :output req)))
-    (when suffix (setcdr cell (concat (cdr cell) suffix)))
-    (cdr cell)))
-
 (defsubst fuel-con--request-deactivate (req)
   (setcdr (assoc :continuation req) nil))
 
index 936bded3a5299e874280a055ee3badfb85405f59..7785c043df183a122f303154266d55f22c9a64f4 100644 (file)
 (defsubst fuel-syntax--at-using ()
   (looking-at fuel-syntax--using-lines-regex))
 
+(defun fuel-syntax--in-using ()
+  (let ((p (point)))
+    (save-excursion
+      (and (re-search-backward "^USING: " nil t)
+           (re-search-forward " ;" nil t)
+           (< p (match-end 0))))))
+
 (defsubst fuel-syntax--beginning-of-defun (&optional times)
   (re-search-backward fuel-syntax--begin-of-def-regex nil t times))