]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: Use font-locks data to figure out if the token point is on is a vocab
authorBjörn Lindqvist <bjourne@gmail.com>
Thu, 17 Apr 2014 16:39:10 +0000 (18:39 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 18 Apr 2014 15:43:11 +0000 (08:43 -0700)
If point is on "myvocab" in IN: myvocab fuel-help will now understand
that it is on a vocabulary token.

misc/fuel/factor-mode.el
misc/fuel/fuel-autodoc.el
misc/fuel/fuel-completion.el
misc/fuel/fuel-help.el

index 0e089294b5ed9028a1d61515296b5cda8eecafac..bcb22b8b2c3634d52d54174b9ca7455e9156c5b8 100644 (file)
@@ -628,12 +628,10 @@ source/docs/tests file. When set to false, you'll be asked only once."
     (beginning-of-line)
     (re-search-forward factor-constructor-regex (line-end-position) t)))
 
-(defun factor-in-using ()
-  (let ((p (point)))
-    (save-excursion
-      (and (re-search-backward "^USING:[ \n]" nil t)
-           (re-search-forward " ;" nil t)
-           (< p (match-end 0))))))
+(defun factor-on-vocab ()
+  "t if point is on a vocab name. We just piggyback on
+  font-lock's pretty accurate information."
+  (eq (get-char-property (point) 'face) 'factor-font-lock-vocabulary-name))
 
 (defsubst factor-end-of-defun-pos ()
   (save-excursion
index 1bf88f2f4386f6279f1c438a937f68adda5c6473..2ac2926139d6336b70632eb8c4ce4356896c8bfd 100644 (file)
@@ -58,7 +58,7 @@ USING: form with \\[fuel-load-usings]."
         (fuel-log--inhibit-p t))
     (when word
       (let* ((usings (if fuel-autodoc-eval-using-form-p :usings t))
-             (cmd (if (factor-in-using)
+             (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))
index 50325af776daa224f416eb9e257ffeaba625036b..bc4816f6c50f7c59980d9300323589111fb38076 100644 (file)
@@ -196,7 +196,7 @@ Perform completion similar to Emacs' complete-symbol."
   (let* ((end (point))
          (beg (save-excursion (factor-beginning-of-symbol) (point)))
          (prefix (buffer-substring-no-properties beg end))
-         (result (fuel-completion--complete prefix (factor-in-using)))
+         (result (fuel-completion--complete prefix (factor-on-vocab)))
          (completions (car result))
          (partial (cdr result)))
     (cond ((null completions)
index e3c7699f9b8fbcceb3ca630097bb0e03a7c5ff91..75fe1f6d150179e45a78fe79d16f25a34283338e 100644 (file)
   "Show extended help about the word or vocabulary at point, using a
 help buffer."
   (interactive "p")
-  (if (factor-in-using)
+  (if (factor-on-vocab)
       (fuel-help-vocab (factor-symbol-at-point))
     (fuel-help--word-help nil nil print-message)))