comparison lisp/cedet/semantic/ia.el @ 104522:2a2b8ae24b17

* cedet/semantic/symref/list.el: Require semantic/complete. (semantic-symref-symbol): Use semantic-complete-read-tag-buffer-deep. * cedet/semantic/ia.el (semantic-ia-complete-symbol-menu): Remove. (semantic-ia-complete-symbol): Use semantic-complete-symbol.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 27 Sep 2009 03:59:51 +0000
parents c89254e41c98
children 7f4c7f5c0eba
comparison
equal deleted inserted replaced
104521:6d72a8365359 104522:2a2b8ae24b17
33 ;;; TODO 33 ;;; TODO
34 ;; 34 ;;
35 ;; fast-jump. For a virtual method, offer some of the possible 35 ;; fast-jump. For a virtual method, offer some of the possible
36 ;; implementations in various sub-classes. 36 ;; implementations in various sub-classes.
37 37
38 ;; (require 'senator)
39 (require 'semantic/analyze) 38 (require 'semantic/analyze)
40 (require 'semantic/format) 39 (require 'semantic/format)
41 (require 'pulse) 40 (require 'pulse)
42 (eval-when-compile 41 (eval-when-compile
43 (require 'semantic/analyze) 42 (require 'semantic/analyze)
135 ;; smart completions, lets divert to how senator derives 134 ;; smart completions, lets divert to how senator derives
136 ;; completions. 135 ;; completions.
137 ;; 136 ;;
138 ;; This is a way of making this fcn more useful since the 137 ;; This is a way of making this fcn more useful since the
139 ;; smart completion engine sometimes failes. 138 ;; smart completion engine sometimes failes.
140 (senator-complete-symbol) 139 (semantic-complete-symbol)))
141 ))
142 ;; Use try completion to seek a common substring. 140 ;; Use try completion to seek a common substring.
143 (let ((tc (try-completion (or pre "") syms))) 141 (let ((tc (try-completion (or pre "") syms)))
144 (if (and (stringp tc) (not (string= tc (or pre "")))) 142 (if (and (stringp tc) (not (string= tc (or pre ""))))
145 (let ((tok (semantic-find-first-tag-by-name 143 (let ((tok (semantic-find-first-tag-by-name
146 tc syms))) 144 tc syms)))
164 (defcustom semantic-ia-completion-menu-format-tag-function 162 (defcustom semantic-ia-completion-menu-format-tag-function
165 'semantic-uml-concise-prototype-nonterminal 163 'semantic-uml-concise-prototype-nonterminal
166 "*Function used to convert a tag to a string during completion." 164 "*Function used to convert a tag to a string during completion."
167 :group 'semantic 165 :group 'semantic
168 :type semantic-format-tag-custom-list) 166 :type semantic-format-tag-custom-list)
169
170 ;;;###autoload
171 (defun semantic-ia-complete-symbol-menu (point)
172 "Complete the current symbol via a menu based at POINT.
173 Completion options are calculated with `semantic-analyze-possible-completions'."
174 (interactive "d")
175 (require 'imenu)
176 (let* ((a (semantic-analyze-current-context point))
177 (syms (semantic-ia-get-completions a point))
178 )
179 ;; Complete this symbol.
180 (if (not syms)
181 (progn
182 (message "No smart completions found. Trying Senator.")
183 (when (semantic-analyze-context-p a)
184 ;; This is a quick way of getting a nice completion list
185 ;; in the menu if the regular context mechanism fails.
186 (senator-completion-menu-popup)))
187
188 (let* ((menu
189 (mapcar
190 (lambda (tag)
191 (cons
192 (funcall semantic-ia-completion-menu-format-tag-function tag)
193 (vector tag)))
194 syms))
195 (ans
196 (imenu--mouse-menu
197 ;; XEmacs needs that the menu has at least 2 items. So,
198 ;; include a nil item that will be ignored by imenu.
199 (cons nil menu)
200 (senator-completion-menu-point-as-event)
201 "Completions")))
202 (when ans
203 (if (not (semantic-tag-p ans))
204 (setq ans (aref (cdr ans) 0)))
205 (delete-region (car (oref a bounds)) (cdr (oref a bounds)))
206 (semantic-ia-insert-tag ans))
207 ))))
208 167
209 ;;; Completions Tip 168 ;;; Completions Tip
210 ;; 169 ;;
211 ;; This functions shows how to get the list of completions, 170 ;; This functions shows how to get the list of completions,
212 ;; to place in a tooltip. It doesn't actually do any completion. 171 ;; to place in a tooltip. It doesn't actually do any completion.