From 2cc6810ea6ec731503396aedbc5fcad0961a901f Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Thu, 18 Dec 2008 00:49:01 +0100 Subject: [PATCH] FUEL: M-. completes vocab names when in USING: stanza. --- extra/fuel/fuel.factor | 4 +++- misc/fuel/fuel-completion.el | 12 +++++++++--- misc/fuel/fuel-connection.el | 8 +------- misc/fuel/fuel-syntax.el | 7 +++++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 15b9adf870..dacf57cc7f 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -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 diff --git a/misc/fuel/fuel-completion.el b/misc/fuel/fuel-completion.el index a4f467fd98..c7340c7037 100644 --- a/misc/fuel/fuel-completion.el +++ b/misc/fuel/fuel-completion.el @@ -32,6 +32,10 @@ (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) diff --git a/misc/fuel/fuel-connection.el b/misc/fuel/fuel-connection.el index 641e1833b9..3cac40bd16 100644 --- a/misc/fuel/fuel-connection.el +++ b/misc/fuel/fuel-connection.el @@ -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))) @@ -64,11 +63,6 @@ (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)) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 936bded3a5..7785c043df 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -232,6 +232,13 @@ (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))