Function: semantic-grammar-complete

semantic-grammar-complete is an interactive and byte-compiled function defined in grammar.el.gz.

Signature

(semantic-grammar-complete)

Documentation

Attempt to complete the symbol under point.

Completion is position sensitive. If the cursor is in a match section of a rule, then nonterminals symbols are scanned. If the cursor is in a Lisp expression then Lisp symbols are completed.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/grammar.el.gz
(defun semantic-grammar-complete ()
  "Attempt to complete the symbol under point.
Completion is position sensitive.  If the cursor is in a match section of
a rule, then nonterminals symbols are scanned.  If the cursor is in a Lisp
expression then Lisp symbols are completed."
  (interactive)
  (if (semantic-grammar-in-lisp-p)
      ;; We are in lisp code.  Do lisp completion.
      (let ((completion-at-point-functions
             (append '(lisp-completion-at-point)
                     completion-at-point-functions)))
        (completion-at-point))
    ;; We are not in lisp code.  Do rule completion.
    (let* ((nonterms (semantic-find-tags-by-class 'nonterminal (current-buffer)))
           (sym (car (semantic-ctxt-current-symbol)))
           (ans (try-completion sym nonterms)))
      (cond ((eq ans t)
             ;; All done
             (message "Symbols is already complete"))
            ((and (stringp ans) (string= ans sym))
             ;; Max matchable.  Show completions.
	     (with-output-to-temp-buffer "*Completions*"
	       (display-completion-list (all-completions sym nonterms)))
	     )
            ((stringp ans)
             ;; Expand the completions
             (forward-sexp -1)
             (delete-region (point) (progn (forward-sexp 1) (point)))
             (insert ans))
            (t (message "No Completions."))
            ))
    ))