From 48111a857162c91287bc77f11b1df83c4bfdf944 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Wed, 28 Apr 2010 15:04:16 -0400 Subject: Unify complete-symbol with completion-at-point. * bindings.el (complete-symbol): Move into minibuffer.el. * minibuffer.el (complete-tag): Move from etags.el. If tags completion cannot be performed, return nil instead of signalling an error. (completion-at-point): Make it an alias for complete-symbol. (complete-symbol): Move from bindings.el, and replace with the body of completion-at-point. * progmodes/etags.el (complete-tag): Move to minibuffer.el. * cedet/semantic.el (semantic-mode): When enabled, add semantic-ia-complete-symbol to completion-at-point-functions. * cedet/semantic/ia.el (semantic-ia-complete-symbol): Return nil if Semantic is not active. --- lisp/cedet/semantic/ia.el | 86 ++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 45 deletions(-) (limited to 'lisp/cedet/semantic') diff --git a/lisp/cedet/semantic/ia.el b/lisp/cedet/semantic/ia.el index 2e926005ea..710b52f37d 100644 --- a/lisp/cedet/semantic/ia.el +++ b/lisp/cedet/semantic/ia.el @@ -110,56 +110,52 @@ Supports caching." If POS is nil, default to point. Completion options are calculated with `semantic-analyze-possible-completions'." (interactive "d") - (or pos (setq pos (point))) - ;; Calculating completions is a two step process. - ;; - ;; The first analyzer the current context, which finds tags - ;; for all the stuff that may be references by the code around - ;; POS. - ;; - ;; The second step derives completions from that context. - (let* ((a (semantic-analyze-current-context pos)) - (syms (semantic-ia-get-completions a pos)) - (pre (car (reverse (oref a prefix)))) - ) - ;; If PRE was actually an already completed symbol, it doesn't - ;; come in as a string, but as a tag instead. - (if (semantic-tag-p pre) - ;; We will try completions on it anyway. - (setq pre (semantic-tag-name pre))) - ;; Complete this symbol. - (if (null syms) - (progn - ;(message "No smart completions found. Trying senator-complete-symbol.") + (when (semantic-active-p) + (or pos (setq pos (point))) + ;; Calculating completions is a two step process. + ;; + ;; The first analyzer the current context, which finds tags for + ;; all the stuff that may be references by the code around POS. + ;; + ;; The second step derives completions from that context. + (let* ((a (semantic-analyze-current-context pos)) + (syms (semantic-ia-get-completions a pos)) + (pre (car (reverse (oref a prefix))))) + ;; If PRE was actually an already completed symbol, it doesn't + ;; come in as a string, but as a tag instead. + (if (semantic-tag-p pre) + ;; We will try completions on it anyway. + (setq pre (semantic-tag-name pre))) + ;; Complete this symbol. + (if (null syms) (if (semantic-analyze-context-p a) ;; This is a clever hack. If we were unable to find any ;; smart completions, lets divert to how senator derives ;; completions. ;; - ;; This is a way of making this fcn more useful since the - ;; smart completion engine sometimes failes. - (semantic-complete-symbol))) - ;; Use try completion to seek a common substring. - (let ((tc (try-completion (or pre "") syms))) - (if (and (stringp tc) (not (string= tc (or pre "")))) - (let ((tok (semantic-find-first-tag-by-name - tc syms))) - ;; Delete what came before... - (when (and (car (oref a bounds)) (cdr (oref a bounds))) - (delete-region (car (oref a bounds)) - (cdr (oref a bounds))) - (goto-char (car (oref a bounds)))) - ;; We have some new text. Stick it in. - (if tok - (semantic-ia-insert-tag tok) - (insert tc))) - ;; We don't have new text. Show all completions. - (when (cdr (oref a bounds)) - (goto-char (cdr (oref a bounds)))) - (with-output-to-temp-buffer "*Completions*" - (display-completion-list - (mapcar semantic-ia-completion-format-tag-function syms)) - )))))) + ;; This is a way of making this fcn more useful since + ;; the smart completion engine sometimes failes. + (semantic-complete-symbol)) + ;; Use try completion to seek a common substring. + (let ((tc (try-completion (or pre "") syms))) + (if (and (stringp tc) (not (string= tc (or pre "")))) + (let ((tok (semantic-find-first-tag-by-name + tc syms))) + ;; Delete what came before... + (when (and (car (oref a bounds)) (cdr (oref a bounds))) + (delete-region (car (oref a bounds)) + (cdr (oref a bounds))) + (goto-char (car (oref a bounds)))) + ;; We have some new text. Stick it in. + (if tok + (semantic-ia-insert-tag tok) + (insert tc))) + ;; We don't have new text. Show all completions. + (when (cdr (oref a bounds)) + (goto-char (cdr (oref a bounds)))) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list + (mapcar semantic-ia-completion-format-tag-function syms))))))))) (defcustom semantic-ia-completion-menu-format-tag-function 'semantic-uml-concise-prototype-nonterminal -- cgit v1.2.3