Function: semantic-complete-current-match
semantic-complete-current-match is a byte-compiled function defined in
complete.el.gz.
Signature
(semantic-complete-current-match)
Documentation
Calculate a match from the current completion environment.
Save this in our completion variable. Make sure that variable
is cleared if any other keypress is made.
Return value can be:
tag - a single tag that has been matched.
string - a message to show in the minibuffer.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/complete.el.gz
(defun semantic-complete-current-match ()
"Calculate a match from the current completion environment.
Save this in our completion variable. Make sure that variable
is cleared if any other keypress is made.
Return value can be:
tag - a single tag that has been matched.
string - a message to show in the minibuffer."
;; Query the environment for an active completion.
(let ((collector semantic-completion-collector-engine)
(displayer semantic-completion-display-engine)
(contents (semantic-completion-text))
matchlist
answer)
(if (string= contents "")
;; The user wants the defaults!
(setq answer semantic-complete-active-default)
;; This forces a full calculation of completion on CR.
(save-excursion
(semantic-collector-calculate-completions collector contents nil))
(semantic-complete-try-completion)
(cond
;; Input match displayer focus entry
((setq answer (semantic-displayer-current-focus displayer))
;; We have answer, continue
)
;; One match from the collector
((setq matchlist (semantic-collector-current-exact-match collector))
(if (= (semanticdb-find-result-length matchlist) 1)
(setq answer (semanticdb-find-result-nth-in-buffer matchlist 0))
(if (semantic-displayer-focus-abstract-child-p displayer)
;; For focusing displayers, we can claim this is
;; not unique. Multiple focuses can choose the correct
;; one.
(setq answer "Not Unique")
;; If we don't have a focusing displayer, we need to do something
;; graceful. First, see if all the matches have the same name.
(let ((allsame t)
(firstname (semantic-tag-name
(car
(semanticdb-find-result-nth matchlist 0)))
)
(cnt 1)
(max (semanticdb-find-result-length matchlist)))
(while (and allsame (< cnt max))
(if (not (string=
firstname
(semantic-tag-name
(car
(semanticdb-find-result-nth matchlist cnt)))))
(setq allsame nil))
(setq cnt (1+ cnt))
)
;; Now we know if they are all the same. If they are, just
;; accept the first, otherwise complain.
(if allsame
(setq answer (semanticdb-find-result-nth-in-buffer
matchlist 0))
(setq answer "Not Unique"))
))))
;; No match
(t
(setq answer "No Match")))
)
;; Set it into our completion target.
(when (semantic-tag-p answer)
(setq semantic-complete-current-matched-tag answer)
;; Make sure it is up to date by clearing it if the user dares
;; to touch the keyboard.
(add-hook 'pre-command-hook
(lambda () (setq semantic-complete-current-matched-tag nil)))
)
;; Return it
answer
))