1 ;;; semantic/complete.el --- Routines for performing tag completion
3 ;;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
4 ;;; Free Software Foundation, Inc.
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; Completion of tags by name using tables of semantic generated tags.
28 ;; While it would be a simple matter of flattening all tag known
29 ;; tables to perform completion across them using `all-completions',
30 ;; or `try-completion', that process would be slow. In particular,
31 ;; when a system database is included in the mix, the potential for a
32 ;; ludicrous number of options becomes apparent.
34 ;; As such, dynamically searching across tables using a prefix,
35 ;; regular expression, or other feature is needed to help find symbols
36 ;; quickly without resorting to "show me every possible option now".
38 ;; In addition, some symbol names will appear in multiple locations.
39 ;; If it is important to distiguish, then a way to provide a choice
40 ;; over these locations is important as well.
42 ;; Beyond brute force offers for completion of plain strings,
43 ;; using the smarts of semantic-analyze to provide reduced lists of
44 ;; symbols, or fancy tabbing to zoom into files to show multiple hits
45 ;; of the same name can be provided.
49 ;; There are several parts of any completion engine. They are:
51 ;; A. Collection of possible hits
52 ;; B. Typing or selecting an option
53 ;; C. Displaying possible unique completions
54 ;; D. Using the result
56 ;; Here, we will treat each section separately (excluding D)
57 ;; They can then be strung together in user-visible commands to
58 ;; fullfill specific needs.
62 ;; A collector is an object which represents the means by which tags
63 ;; to complete on are collected. It's first job is to find all the
64 ;; tags which are to be completed against. It can also rename
65 ;; some tags if needed so long as `semantic-tag-clone' is used.
67 ;; Some collectors will gather all tags to complete against first
68 ;; (for in buffer queries, or other small list situations). It may
69 ;; choose to do a broad search on each completion request. Built in
70 ;; functionality automatically focuses the cache in as the user types.
72 ;; A collector choosing to create and rename tags could choose a
73 ;; plain name format, a postfix name such as method:class, or a
74 ;; prefix name such as class.method.
78 ;; A displayor is in charge if showing the user interesting things
79 ;; about available completions, and can optionally provide a focus.
80 ;; The simplest display just lists all available names in a separate
81 ;; window. It may even choose to show short names when there are
82 ;; many to choose from, or long names when there are fewer.
84 ;; A complex displayor could opt to help the user 'focus' on some
85 ;; range. For example, if 4 tags all have the same name, subsequent
86 ;; calls to the displayor may opt to show each tag one at a time in
87 ;; the buffer. When the user likes one, selection would cause the
88 ;; 'focus' item to be selected.
92 ;; The format of the tag lists used to perform the completions are in
93 ;; semanticdb "find" format, like this:
95 ;; ( ( DBTABLE1 TAG1 TAG2 ...)
96 ;; ( DBTABLE2 TAG1 TAG2 ...)
99 ;; INLINE vs MINIBUFFER
101 ;; Two major ways completion is used in Emacs is either through a
102 ;; minibuffer query, or via completion in a normal editing buffer,
103 ;; encompassing some small range of characters.
105 ;; Structure for both types of completion are provided here.
106 ;; `semantic-complete-read-tag-engine' will use the minibuffer.
107 ;; `semantic-complete-inline-tag-engine' will complete text in
113 (require 'semantic
/analyze
)
114 (require 'semantic
/ctxt
)
115 (require 'semantic
/decorate
)
116 (require 'semantic
/format
)
117 (require 'semantic
/tag
)
120 ;; For the semantic-find-tags-for-completion macro.
121 (require 'semantic
/find
))
125 ;; Tooltip not available in older emacsen.
134 (if (fboundp 'minibuffer-contents
)
135 (eval-and-compile (defalias 'semantic-minibuffer-contents
'minibuffer-contents
))
136 (eval-and-compile (defalias 'semantic-minibuffer-contents
'buffer-string
)))
137 (if (fboundp 'delete-minibuffer-contents
)
138 (eval-and-compile (defalias 'semantic-delete-minibuffer-contents
'delete-minibuffer-contents
))
139 (eval-and-compile (defalias 'semantic-delete-minibuffer-contents
'erase-buffer
)))
141 (defvar semantic-complete-inline-overlay nil
142 "The overlay currently active while completing inline.")
144 (defun semantic-completion-inline-active-p ()
145 "Non-nil if inline completion is active."
146 (when (and semantic-complete-inline-overlay
147 (not (semantic-overlay-live-p semantic-complete-inline-overlay
)))
148 (semantic-overlay-delete semantic-complete-inline-overlay
)
149 (setq semantic-complete-inline-overlay nil
))
150 semantic-complete-inline-overlay
)
152 ;;; ------------------------------------------------------------
153 ;;; MINIBUFFER or INLINE utils
155 (defun semantic-completion-text ()
156 "Return the text that is currently in the completion buffer.
157 For a minibuffer prompt, this is the minibuffer text.
158 For inline completion, this is the text wrapped in the inline completion
160 (if semantic-complete-inline-overlay
161 (semantic-complete-inline-text)
162 (semantic-minibuffer-contents)))
164 (defun semantic-completion-delete-text ()
165 "Delete the text that is actively being completed.
166 Presumably if you call this you will insert something new there."
167 (if semantic-complete-inline-overlay
168 (semantic-complete-inline-delete-text)
169 (semantic-delete-minibuffer-contents)))
171 (defun semantic-completion-message (fmt &rest args
)
172 "Display the string FMT formatted with ARGS at the end of the minibuffer."
173 (if semantic-complete-inline-overlay
174 (apply 'message fmt args
)
175 (message (concat (buffer-string) (apply 'format fmt args
)))))
177 ;;; ------------------------------------------------------------
178 ;;; MINIBUFFER: Option Selection harnesses
180 (defvar semantic-completion-collector-engine nil
181 "The tag collector for the current completion operation.
182 Value should be an object of a subclass of
183 `semantic-completion-engine-abstract'.")
185 (defvar semantic-completion-display-engine nil
186 "The tag display engine for the current completion operation.
187 Value should be a ... what?")
189 (defvar semantic-complete-key-map
190 (let ((km (make-sparse-keymap)))
191 (define-key km
" " 'semantic-complete-complete-space
)
192 (define-key km
"\t" 'semantic-complete-complete-tab
)
193 (define-key km
"\C-m" 'semantic-complete-done
)
194 (define-key km
"\C-g" 'abort-recursive-edit
)
195 (define-key km
"\M-n" 'next-history-element
)
196 (define-key km
"\M-p" 'previous-history-element
)
197 (define-key km
"\C-n" 'next-history-element
)
198 (define-key km
"\C-p" 'previous-history-element
)
199 ;; Add history navigation
201 "Keymap used while completing across a list of tags.")
203 (defvar semantic-completion-default-history nil
204 "Default history variable for any unhistoried prompt.
205 Keeps STRINGS only in the history.")
208 (defun semantic-complete-read-tag-engine (collector displayor prompt
209 default-tag initial-input
211 "Read a semantic tag, and return a tag for the selection.
212 Argument COLLECTOR is an object which can be used to to calculate
213 a list of possible hits. See `semantic-completion-collector-engine'
214 for details on COLLECTOR.
215 Argumeng DISPLAYOR is an object used to display a list of possible
216 completions for a given prefix. See`semantic-completion-display-engine'
217 for details on DISPLAYOR.
218 PROMPT is a string to prompt with.
219 DEFAULT-TAG is a semantic tag or string to use as the default value.
220 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
221 HISTORY is a symbol representing a variable to story the history in."
222 (let* ((semantic-completion-collector-engine collector
)
223 (semantic-completion-display-engine displayor
)
224 (semantic-complete-active-default nil
)
225 (semantic-complete-current-matched-tag nil
)
226 (default-as-tag (semantic-complete-default-to-tag default-tag
))
227 (default-as-string (when (semantic-tag-p default-as-tag
)
228 (semantic-tag-name default-as-tag
)))
231 (when default-as-string
232 ;; Add this to the prompt.
234 ;; I really want to add a lookup of the symbol in those
235 ;; tags available to the collector and only add it if it
236 ;; is available as a possibility, but I'm too lazy right
240 ;; @todo - move from () to into the editable area
241 (if (string-match ":" prompt
)
243 (substring prompt
0 (match-beginning 0))
244 " (" default-as-string
")"
245 (substring prompt
(match-beginning 0))))
246 (setq prompt
(concat prompt
" (" default-as-string
"): "))))
248 ;; Perform the Completion
251 (read-from-minibuffer prompt
253 semantic-complete-key-map
256 'semantic-completion-default-history
)
258 (semantic-collector-cleanup semantic-completion-collector-engine
)
259 (semantic-displayor-cleanup semantic-completion-display-engine
)
262 ;; Extract the tag from the completion machinery.
264 semantic-complete-current-matched-tag
268 ;;; Util for basic completion prompts
271 (defvar semantic-complete-active-default nil
272 "The current default tag calculated for this prompt.")
274 (defun semantic-complete-default-to-tag (default)
275 "Convert a calculated or passed in DEFAULT into a tag."
276 (if (semantic-tag-p default
)
277 ;; Just return what was passed in.
278 (setq semantic-complete-active-default default
)
279 ;; If none was passed in, guess.
281 (setq default
(semantic-ctxt-current-thing)))
285 ;; Turn default into something useful.
288 ;; Semantic-ctxt-current-symbol will return a list of
289 ;; strings. Technically, we should use the analyzer to
290 ;; fully extract what we need, but for now, just grab the
292 ((and (listp default
) (stringp (car default
)))
297 (symbol-name default
))
299 (signal 'wrong-type-argument
300 (list default
'semantic-tag-p
)))))
302 ;; Now that we have that symbol string, look it up using the active
303 ;; collector. If we get a match, use it.
305 (semantic-collector-calculate-completions
306 semantic-completion-collector-engine
308 ;; Do we have the perfect match???
309 (let ((ml (semantic-collector-current-exact-match
310 semantic-completion-collector-engine
)))
312 ;; We don't care about uniqueness. Just guess for convenience
313 (setq tag
(semanticdb-find-result-nth-in-buffer ml
0))))
315 (setq semantic-complete-active-default tag
)
316 ;; Return it.. .whatever it may be
320 ;;; Prompt Return Value
322 ;; Getting a return value out of this completion prompt is a bit
323 ;; challenging. The read command returns the string typed in.
324 ;; We need to convert this into a valid tag. We can exit the minibuffer
325 ;; for different reasons. If we purposely exit, we must make sure
326 ;; the focused tag is calculated... preferably once.
327 (defvar semantic-complete-current-matched-tag nil
328 "Variable used to pass the tags being matched to the prompt.")
330 ;; semantic-displayor-focus-abstract-child-p is part of the
331 ;; semantic-displayor-focus-abstract class, defined later in this
333 (declare-function semantic-displayor-focus-abstract-child-p
"semantic/complete")
335 (defun semantic-complete-current-match ()
336 "Calculate a match from the current completion environment.
337 Save this in our completion variable. Make sure that variable
338 is cleared if any other keypress is made.
340 tag - a single tag that has been matched.
341 string - a message to show in the minibuffer."
342 ;; Query the environment for an active completion.
343 (let ((collector semantic-completion-collector-engine
)
344 (displayor semantic-completion-display-engine
)
345 (contents (semantic-completion-text))
348 (if (string= contents
"")
349 ;; The user wants the defaults!
350 (setq answer semantic-complete-active-default
)
351 ;; This forces a full calculation of completion on CR.
353 (semantic-collector-calculate-completions collector contents nil
))
354 (semantic-complete-try-completion)
356 ;; Input match displayor focus entry
357 ((setq answer
(semantic-displayor-current-focus displayor
))
358 ;; We have answer, continue
360 ;; One match from the collector
361 ((setq matchlist
(semantic-collector-current-exact-match collector
))
362 (if (= (semanticdb-find-result-length matchlist
) 1)
363 (setq answer
(semanticdb-find-result-nth-in-buffer matchlist
0))
364 (if (semantic-displayor-focus-abstract-child-p displayor
)
365 ;; For focusing displayors, we can claim this is
366 ;; not unique. Multiple focuses can choose the correct
368 (setq answer
"Not Unique")
369 ;; If we don't have a focusing displayor, we need to do something
370 ;; graceful. First, see if all the matches have the same name.
372 (firstname (semantic-tag-name
374 (semanticdb-find-result-nth matchlist
0)))
377 (max (semanticdb-find-result-length matchlist
)))
378 (while (and allsame
(< cnt max
))
383 (semanticdb-find-result-nth matchlist cnt
)))))
387 ;; Now we know if they are all the same. If they are, just
388 ;; accept the first, otherwise complain.
390 (setq answer
(semanticdb-find-result-nth-in-buffer
392 (setq answer
"Not Unique"))
396 (setq answer
"No Match")))
398 ;; Set it into our completion target.
399 (when (semantic-tag-p answer
)
400 (setq semantic-complete-current-matched-tag answer
)
401 ;; Make sure it is up to date by clearing it if the user dares
402 ;; to touch the keyboard.
403 (add-hook 'pre-command-hook
404 (lambda () (setq semantic-complete-current-matched-tag nil
)))
413 ;; Keys are bound to to perform completion using our mechanisms.
414 ;; Do that work here.
415 (defun semantic-complete-done ()
416 "Accept the current input."
418 (let ((ans (semantic-complete-current-match)))
420 (semantic-completion-message (concat " [" ans
"]"))
424 (defun semantic-complete-complete-space ()
425 "Complete the partial input in the minibuffer."
427 (semantic-complete-do-completion t
))
429 (defun semantic-complete-complete-tab ()
430 "Complete the partial input in the minibuffer as far as possible."
432 (semantic-complete-do-completion))
434 ;;; Completion Functions
436 ;; Thees routines are functional entry points to performing completion.
438 (defun semantic-complete-hack-word-boundaries (original new
)
439 "Return a string to use for completion.
440 ORIGINAL is the text in the minibuffer.
441 NEW is the new text to insert into the minibuffer.
442 Within the difference bounds of ORIGINAL and NEW, shorten NEW
443 to the nearest word boundary, and return that."
445 (let* ((diff (substring new
(length original
)))
446 (end (string-match "\\>" diff
))
447 (start (string-match "\\<" diff
)))
449 ((and start
(> start
0))
450 ;; If start is greater than 0, include only the new
452 (concat original
(substring diff
0 start
)))
454 (concat original
(substring diff
0 end
)))
457 (defun semantic-complete-try-completion (&optional partial
)
458 "Try a completion for the current minibuffer.
459 If PARTIAL, do partial completion stopping at spaces."
460 (let ((comp (semantic-collector-try-completion
461 semantic-completion-collector-engine
462 (semantic-completion-text))))
465 (semantic-completion-message " [No Match]")
469 (if (string= (semantic-completion-text) comp
)
471 ;; Minibuffer isn't changing AND the text is not unique.
472 ;; Test for partial completion over a word separator character.
473 ;; If there is one available, use that so that SPC can
474 ;; act like a SPC insert key.
475 (let ((newcomp (semantic-collector-current-whitespace-completion
476 semantic-completion-collector-engine
)))
478 (semantic-completion-delete-text)
482 (let ((orig (semantic-completion-text)))
483 ;; For partial completion, we stop and step over
484 ;; word boundaries. Use this nifty function to do
485 ;; that calculation for us.
487 (semantic-complete-hack-word-boundaries orig comp
))))
488 ;; Do the replacement.
489 (semantic-completion-delete-text)
492 ((and (listp comp
) (semantic-tag-p (car comp
)))
493 (unless (string= (semantic-completion-text)
494 (semantic-tag-name (car comp
)))
495 ;; A fully unique completion was available.
496 (semantic-completion-delete-text)
497 (insert (semantic-tag-name (car comp
))))
498 ;; The match is complete
499 (if (= (length comp
) 1)
500 (semantic-completion-message " [Complete]")
501 (semantic-completion-message " [Complete, but not unique]"))
505 (defun semantic-complete-do-completion (&optional partial inline
)
506 "Do a completion for the current minibuffer.
507 If PARTIAL, do partial completion stopping at spaces.
508 if INLINE, then completion is happening inline in a buffer."
509 (let* ((collector semantic-completion-collector-engine
)
510 (displayor semantic-completion-display-engine
)
511 (contents (semantic-completion-text))
515 (semantic-collector-calculate-completions collector contents partial
))
516 (let* ((na (semantic-complete-next-action partial
)))
518 ;; We're all done, but only from a very specific
519 ;; area of completion.
521 (semantic-completion-message " [Complete]")
523 ;; Perform completion
524 ((or (eq na
'complete
)
525 (eq na
'complete-whitespace
))
526 (semantic-complete-try-completion partial
)
527 (setq ans
'complete
))
528 ;; We need to display the completions.
529 ;; Set the completions into the display engine
530 ((or (eq na
'display
) (eq na
'displayend
))
531 (semantic-displayor-set-completions
534 (and (not (eq na
'displayend
))
535 (semantic-collector-current-exact-match collector
))
536 (semantic-collector-all-completions collector contents
))
538 ;; Ask the displayor to display them.
539 (semantic-displayor-show-request displayor
))
541 (semantic-displayor-scroll-request displayor
)
544 (semantic-displayor-focus-next displayor
)
545 (semantic-displayor-focus-request displayor
)
548 (semantic-completion-message " [No Match]"))
553 ;;; ------------------------------------------------------------
554 ;;; INLINE: tag completion harness
556 ;; Unlike the minibuffer, there is no mode nor other traditional
557 ;; means of reading user commands in completion mode. Instead
558 ;; we use a pre-command-hook to inset in our commands, and to
559 ;; push ourselves out of this mode on alternate keypresses.
560 (defvar semantic-complete-inline-map
561 (let ((km (make-sparse-keymap)))
562 (define-key km
"\C-i" 'semantic-complete-inline-TAB
)
563 (define-key km
"\M-p" 'semantic-complete-inline-up
)
564 (define-key km
"\M-n" 'semantic-complete-inline-down
)
565 (define-key km
"\C-m" 'semantic-complete-inline-done
)
566 (define-key km
"\C-\M-c" 'semantic-complete-inline-exit
)
567 (define-key km
"\C-g" 'semantic-complete-inline-quit
)
569 (lambda () (interactive)
570 (describe-variable 'semantic-complete-inline-map
)))
572 "Keymap used while performing Semantic inline completion.
573 \\{semantic-complete-inline-map}")
575 (defface semantic-complete-inline-face
576 '((((class color
) (background dark
))
577 (:underline
"yellow"))
578 (((class color
) (background light
))
579 (:underline
"brown")))
580 "*Face used to show the region being completed inline.
581 The face is used in `semantic-complete-inline-tag-engine'."
582 :group
'semantic-faces
)
584 (defun semantic-complete-inline-text ()
585 "Return the text that is being completed inline.
586 Similar to `minibuffer-contents' when completing in the minibuffer."
587 (let ((s (semantic-overlay-start semantic-complete-inline-overlay
))
588 (e (semantic-overlay-end semantic-complete-inline-overlay
)))
591 (buffer-substring-no-properties s e
))))
593 (defun semantic-complete-inline-delete-text ()
594 "Delete the text currently being completed in the current buffer."
596 (semantic-overlay-start semantic-complete-inline-overlay
)
597 (semantic-overlay-end semantic-complete-inline-overlay
)))
599 (defun semantic-complete-inline-done ()
600 "This completion thing is DONE, OR, insert a newline."
602 (let* ((displayor semantic-completion-display-engine
)
603 (tag (semantic-displayor-current-focus displayor
)))
605 (let ((txt (semantic-completion-text)))
606 (insert (substring (semantic-tag-name tag
)
608 (semantic-complete-inline-exit))
610 ;; Get whatever binding RET usually has.
613 (lookup-key (current-active-maps) (this-command-keys))
615 ;; I don't know why, but for some reason the above
616 ;; throws an error sometimes.
617 (lookup-key (current-global-map) (this-command-keys))
623 (defun semantic-complete-inline-quit ()
624 "Quit an inline edit."
626 (semantic-complete-inline-exit)
629 (defun semantic-complete-inline-exit ()
630 "Exit inline completion mode."
632 ;; Remove this hook FIRST!
633 (remove-hook 'pre-command-hook
'semantic-complete-pre-command-hook
)
637 (when semantic-completion-collector-engine
638 (semantic-collector-cleanup semantic-completion-collector-engine
))
639 (when semantic-completion-display-engine
640 (semantic-displayor-cleanup semantic-completion-display-engine
))
642 (when semantic-complete-inline-overlay
643 (let ((wc (semantic-overlay-get semantic-complete-inline-overlay
644 'window-config-start
))
645 (buf (semantic-overlay-buffer semantic-complete-inline-overlay
))
647 (semantic-overlay-delete semantic-complete-inline-overlay
)
648 (setq semantic-complete-inline-overlay nil
)
649 ;; DONT restore the window configuration if we just
651 (when (eq buf
(current-buffer))
652 (set-window-configuration wc
))
655 (setq semantic-completion-collector-engine nil
656 semantic-completion-display-engine nil
))
659 ;; Remove this hook LAST!!!
660 ;; This will force us back through this function if there was
661 ;; some sort of error above.
662 (remove-hook 'post-command-hook
'semantic-complete-post-command-hook
)
664 ;;(message "Exiting inline completion.")
667 (defun semantic-complete-pre-command-hook ()
668 "Used to redefine what commands are being run while completing.
669 When installed as a `pre-command-hook' the special keymap
670 `semantic-complete-inline-map' is queried to replace commands normally run.
671 Commands which edit what is in the region of interest operate normally.
672 Commands which would take us out of the region of interest, or our
673 quit hook, will exit this completion mode."
674 (let ((fcn (lookup-key semantic-complete-inline-map
675 (this-command-keys) nil
)))
676 (cond ((commandp fcn
)
677 (setq this-command fcn
))
681 (defun semantic-complete-post-command-hook ()
682 "Used to determine if we need to exit inline completion mode.
683 If completion mode is active, check to see if we are within
684 the bounds of `semantic-complete-inline-overlay', or within
685 a reasonable distance."
687 ;; Exit if something bad happened.
688 (if (not semantic-complete-inline-overlay
)
690 ;;(message "Inline Hook installed, but overlay deleted.")
691 (semantic-complete-inline-exit))
692 ;; Exit if commands caused us to exit the area of interest
693 (let ((s (semantic-overlay-start semantic-complete-inline-overlay
))
694 (e (semantic-overlay-end semantic-complete-inline-overlay
))
695 (b (semantic-overlay-buffer semantic-complete-inline-overlay
))
699 ;; EXIT when we are no longer in a good place.
700 ((or (not (eq b
(current-buffer)))
703 ;;(message "Exit: %S %S %S" s e (point))
704 (semantic-complete-inline-exit)
706 ;; Exit if the user typed in a character that is not part
707 ;; of the symbol being completed.
708 ((and (setq txt
(semantic-completion-text))
709 (not (string= txt
""))
713 (not (looking-at "\\(\\w\\|\\s_\\)")))))
714 ;;(message "Non symbol character.")
715 (semantic-complete-inline-exit))
716 ((lookup-key semantic-complete-inline-map
717 (this-command-keys) nil
)
718 ;; If the last command was one of our completion commands,
723 ;; Else, show completions now
724 (semantic-complete-inline-force-display)
727 ;; If something goes terribly wrong, clean up after ourselves.
728 (error (semantic-complete-inline-exit))))
730 (defun semantic-complete-inline-force-display ()
731 "Force the display of whatever the current completions are.
732 DO NOT CALL THIS IF THE INLINE COMPLETION ENGINE IS NOT ACTIVE."
735 (let ((collector semantic-completion-collector-engine
)
736 (displayor semantic-completion-display-engine
)
737 (contents (semantic-completion-text)))
739 (semantic-collector-calculate-completions
740 collector contents nil
)
741 (semantic-displayor-set-completions
743 (semantic-collector-all-completions collector contents
)
745 ;; Ask the displayor to display them.
746 (semantic-displayor-show-request displayor
))
748 (error (message "Bug Showing Completions: %S" e
))))
750 (defun semantic-complete-inline-tag-engine
751 (collector displayor buffer start end
)
752 "Perform completion based on semantic tags in a buffer.
753 Argument COLLECTOR is an object which can be used to to calculate
754 a list of possible hits. See `semantic-completion-collector-engine'
755 for details on COLLECTOR.
756 Argumeng DISPLAYOR is an object used to display a list of possible
757 completions for a given prefix. See`semantic-completion-display-engine'
758 for details on DISPLAYOR.
759 BUFFER is the buffer in which completion will take place.
760 START is a location for the start of the full symbol.
761 If the symbol being completed is \"foo.ba\", then START
762 is on the \"f\" character.
763 END is at the end of the current symbol being completed."
764 ;; Set us up for doing completion
765 (setq semantic-completion-collector-engine collector
766 semantic-completion-display-engine displayor
)
768 (setq semantic-complete-inline-overlay
769 (semantic-make-overlay start end buffer nil t
))
770 (semantic-overlay-put semantic-complete-inline-overlay
772 'semantic-complete-inline-face
)
773 (semantic-overlay-put semantic-complete-inline-overlay
775 (current-window-configuration))
776 ;; Install our command hooks
777 (add-hook 'pre-command-hook
'semantic-complete-pre-command-hook
)
778 (add-hook 'post-command-hook
'semantic-complete-post-command-hook
)
780 (semantic-complete-inline-force-display)
783 ;;; Inline Completion Keymap Functions
785 (defun semantic-complete-inline-TAB ()
786 "Perform inline completion."
788 (let ((cmpl (semantic-complete-do-completion nil t
)))
791 (semantic-complete-inline-force-display))
793 (semantic-complete-inline-done))
797 (defun semantic-complete-inline-down()
798 "Focus forwards through the displayor."
800 (let ((displayor semantic-completion-display-engine
))
801 (semantic-displayor-focus-next displayor
)
802 (semantic-displayor-focus-request displayor
)
805 (defun semantic-complete-inline-up ()
806 "Focus backwards through the displayor."
808 (let ((displayor semantic-completion-display-engine
))
809 (semantic-displayor-focus-previous displayor
)
810 (semantic-displayor-focus-request displayor
)
814 ;;; ------------------------------------------------------------
815 ;;; Interactions between collection and displaying
817 ;; Functional routines used to help collectors communicate with
818 ;; the current displayor, or for the previous section.
820 (defun semantic-complete-next-action (partial)
821 "Determine what the next completion action should be.
822 PARTIAL is non-nil if we are doing partial completion.
823 First, the collector can determine if we should perform a completion or not.
824 If there is nothing to complete, then the displayor determines if we are
825 to show a completion list, scroll, or perhaps do a focus (if it is capable.)
826 Expected return values are:
827 done -> We have a singular match
828 empty -> There are no matches to the current text
829 complete -> Perform a completion action
830 complete-whitespace -> Complete next whitespace type character.
831 display -> Show the list of completions
832 scroll -> The completions have been shown, and the user keeps hitting
833 the complete button. If possible, scroll the completions
834 focus -> The displayor knows how to shift focus among possible completions.
836 displayend -> Whatever options the displayor had for repeating options, there
837 are none left. Try something new."
838 (let ((ans1 (semantic-collector-next-action
839 semantic-completion-collector-engine
841 (ans2 (semantic-displayor-next-action
842 semantic-completion-display-engine
))
845 ;; No collector answer, use displayor answer.
848 ;; Displayor selection of 'scroll, 'display, or 'focus trumps
850 ((and (eq ans1
'done
) ans2
)
852 ;; Use ans1 when we have it.
858 ;;; ------------------------------------------------------------
859 ;;; Collection Engines
861 ;; Collection engines can scan tags from the current environment and
862 ;; provide lists of possible completions.
864 ;; General features of the abstract collector:
865 ;; * Cache completion lists between uses
866 ;; * Cache itself per buffer. Handle reparse hooks
868 ;; Key Interface Functions to implement:
869 ;; * semantic-collector-next-action
870 ;; * semantic-collector-calculate-completions
871 ;; * semantic-collector-try-completion
872 ;; * semantic-collector-all-completions
874 (defvar semantic-collector-per-buffer-list nil
875 "List of collectors active in this buffer.")
876 (make-variable-buffer-local 'semantic-collector-per-buffer-list
)
878 (defvar semantic-collector-list nil
879 "List of global collectors active this session.")
881 (defclass semantic-collector-abstract
()
882 ((buffer :initarg
:buffer
884 :documentation
"Originating buffer for this collector.
885 Some collectors use a given buffer as a starting place while looking up
888 :type
(or null semanticdb-find-result-with-nil
)
889 :documentation
"Cache of tags.
890 These tags are re-used during a completion session.
891 Sometimes these tags are cached between completion sessions.")
892 (last-all-completions :initarg nil
893 :type semanticdb-find-result-with-nil
894 :documentation
"Last result of `all-completions'.
895 This result can be used for refined completions as `last-prefix' gets
896 closer to a specific result.")
897 (last-prefix :type string
898 :protection
:protected
899 :documentation
"The last queried prefix.
900 This prefix can be used to cache intermediate completion offers.
901 making the action of homing in on a token faster.")
902 (last-completion :type
(or null string
)
903 :documentation
"The last calculated completion.
904 This completion is calculated and saved for future use.")
905 (last-whitespace-completion :type
(or null string
)
906 :documentation
"The last whitespace completion.
907 For partial completion, SPC will disabiguate over whitespace type
908 characters. This is the last calculated version.")
909 (current-exact-match :type list
910 :protection
:protected
911 :documentation
"The list of matched tags.
912 When tokens are matched, they are added to this list.")
914 "Root class for completion engines.
915 The baseclass provides basic functionality for interacting with
916 a completion displayor object, and tracking the current progress
920 (defmethod semantic-collector-cleanup ((obj semantic-collector-abstract
))
921 "Clean up any mess this collector may have."
924 (defmethod semantic-collector-next-action
925 ((obj semantic-collector-abstract
) partial
)
926 "What should we do next? OBJ can predict a next good action.
927 PARTIAL indicates if we are doing a partial completion."
928 (if (and (slot-boundp obj
'last-completion
)
929 (string= (semantic-completion-text) (oref obj last-completion
)))
930 (let* ((cem (semantic-collector-current-exact-match obj
))
931 (cemlen (semanticdb-find-result-length cem
))
932 (cac (semantic-collector-all-completions
933 obj
(semantic-completion-text)))
934 (caclen (semanticdb-find-result-length cac
)))
935 (cond ((and cem
(= cemlen
1)
937 (eq last-command this-command
))
938 ;; Defer to the displayor...
940 ((and cem
(= cemlen
1))
942 ((and (not cem
) (not cac
))
944 ((and partial
(semantic-collector-try-completion-whitespace
945 obj
(semantic-completion-text)))
946 'complete-whitespace
)))
949 (defmethod semantic-collector-last-prefix= ((obj semantic-collector-abstract
)
951 "Return non-nil if OBJ's prefix matches PREFIX."
952 (and (slot-boundp obj
'last-prefix
)
953 (string= (oref obj last-prefix
) last-prefix
)))
955 (defmethod semantic-collector-get-cache ((obj semantic-collector-abstract
))
956 "Get the raw cache of tags for completion.
957 Calculate the cache if there isn't one."
959 (semantic-collector-calculate-cache obj
)))
961 (defmethod semantic-collector-calculate-completions-raw
962 ((obj semantic-collector-abstract
) prefix completionlist
)
963 "Calculate the completions for prefix from completionlist.
964 Output must be in semanticdb Find result format."
965 ;; Must output in semanticdb format
966 (let ((table (save-excursion
967 (set-buffer (oref obj buffer
))
968 semanticdb-current-table
))
969 (result (semantic-find-tags-for-completion
971 ;; To do this kind of search with a pre-built completion
972 ;; list, we need to strip it first.
973 (semanticdb-strip-find-results completionlist
)))
976 (list (cons table result
)))))
978 (defmethod semantic-collector-calculate-completions
979 ((obj semantic-collector-abstract
) prefix partial
)
980 "Calculate completions for prefix as setup for other queries."
981 (let* ((case-fold-search semantic-case-fold
)
982 (same-prefix-p (semantic-collector-last-prefix= obj prefix
))
984 (if (or same-prefix-p
985 (and (slot-boundp obj
'last-prefix
)
986 (eq (compare-strings (oref obj last-prefix
) 0 nil
987 prefix
0 (length prefix
))
989 ;; New prefix is subset of old prefix
990 (oref obj last-all-completions
)
991 (semantic-collector-get-cache obj
)))
993 (answer (if same-prefix-p
995 (semantic-collector-calculate-completions-raw
996 obj prefix completionlist
))
999 (complete-not-uniq nil
)
1001 ;;(semanticdb-find-result-test answer)
1002 (when (not same-prefix-p
)
1003 ;; Save results if it is interesting and beneficial
1004 (oset obj last-prefix prefix
)
1005 (oset obj last-all-completions answer
))
1006 ;; Now calculate the completion.
1007 (setq completion
(try-completion
1009 (semanticdb-strip-find-results answer
)))
1010 (oset obj last-whitespace-completion nil
)
1011 (oset obj current-exact-match nil
)
1012 ;; Only do this if a completion was found. Letting a nil in
1013 ;; could cause a full semanticdb search by accident.
1015 (oset obj last-completion
1017 ;; Unique match in AC. Last completion is a match.
1018 ;; Also set the current-exact-match.
1020 (oset obj current-exact-match answer
)
1022 ;; It may be complete (a symbol) but still not unique.
1023 ;; We can capture a match
1024 ((setq complete-not-uniq
1025 (semanticdb-find-tags-by-name
1028 (oset obj current-exact-match
1032 ;; Non unique match, return the string that handles
1034 (t (or completion prefix
))
1038 (defmethod semantic-collector-try-completion-whitespace
1039 ((obj semantic-collector-abstract
) prefix
)
1040 "For OBJ, do whatepsace completion based on PREFIX.
1041 This implies that if there are two completions, one matching
1042 the test \"preifx\\>\", and one not, the one matching the full
1043 word version of PREFIX will be chosen, and that text returned.
1044 This function requires that `semantic-collector-calculate-completions'
1045 has been run first."
1046 (let* ((ac (semantic-collector-all-completions obj prefix
))
1047 (matchme (concat "^" prefix
"\\>"))
1048 (compare (semanticdb-find-tags-by-name-regexp matchme ac
))
1049 (numtag (semanticdb-find-result-length compare
))
1053 (cutlen (1+ (length prefix
)))
1054 (twws (semanticdb-find-result-nth compare idx
)))
1055 ;; Is our tag with whitespace a match that has whitespace
1056 ;; after it, or just an already complete symbol?
1057 (while (and (< idx numtag
)
1058 (< (length (semantic-tag-name (car twws
))) cutlen
))
1060 twws
(semanticdb-find-result-nth compare idx
)))
1061 (when (and twws
(car-safe twws
))
1062 ;; If COMPARE has succeeded, then we should take the very
1063 ;; first match, and extend prefix by one character.
1064 (oset obj last-whitespace-completion
1065 (substring (semantic-tag-name (car twws
))
1070 (defmethod semantic-collector-current-exact-match ((obj semantic-collector-abstract
))
1071 "Return the active valid MATCH from the semantic collector.
1072 For now, just return the first element from our list of available
1073 matches. For semanticdb based results, make sure the file is loaded
1075 (when (slot-boundp obj
'current-exact-match
)
1076 (oref obj current-exact-match
)))
1078 (defmethod semantic-collector-current-whitespace-completion ((obj semantic-collector-abstract
))
1079 "Return the active whitespace completion value."
1080 (when (slot-boundp obj
'last-whitespace-completion
)
1081 (oref obj last-whitespace-completion
)))
1083 (defmethod semantic-collector-get-match ((obj semantic-collector-abstract
))
1084 "Return the active valid MATCH from the semantic collector.
1085 For now, just return the first element from our list of available
1086 matches. For semanticdb based results, make sure the file is loaded
1088 (when (slot-boundp obj
'current-exact-match
)
1089 (semanticdb-find-result-nth-in-buffer (oref obj current-exact-match
) 0)))
1091 (defmethod semantic-collector-all-completions
1092 ((obj semantic-collector-abstract
) prefix
)
1093 "For OBJ, retrieve all completions matching PREFIX.
1094 The returned list consists of all the tags currently
1096 (when (slot-boundp obj
'last-all-completions
)
1097 (oref obj last-all-completions
)))
1099 (defmethod semantic-collector-try-completion
1100 ((obj semantic-collector-abstract
) prefix
)
1101 "For OBJ, attempt to match PREFIX.
1102 See `try-completion' for details on how this works.
1103 Return nil for no match.
1104 Return a string for a partial match.
1105 For a unique match of PREFIX, return the list of all tags
1107 (if (slot-boundp obj
'last-completion
)
1108 (oref obj last-completion
)))
1110 (defmethod semantic-collector-calculate-cache
1111 ((obj semantic-collector-abstract
))
1112 "Calculate the completion cache for OBJ."
1116 (defmethod semantic-collector-flush ((this semantic-collector-abstract
))
1117 "Flush THIS collector object, clearing any caches and prefix."
1118 (oset this cache nil
)
1119 (slot-makeunbound this
'last-prefix
)
1120 (slot-makeunbound this
'last-completion
)
1121 (slot-makeunbound this
'last-all-completions
)
1122 (slot-makeunbound this
'current-exact-match
)
1127 (defclass semantic-collector-buffer-abstract
(semantic-collector-abstract)
1129 "Root class for per-buffer completion engines.
1130 These collectors track themselves on a per-buffer basis."
1133 (defmethod constructor :STATIC
((this semantic-collector-buffer-abstract
)
1134 newname
&rest fields
)
1135 "Reuse previously created objects of this type in buffer."
1137 (bl semantic-collector-per-buffer-list
))
1138 (while (and bl
(null old
))
1139 (if (eq (object-class (car bl
)) this
)
1140 (setq old
(car bl
))))
1142 (let ((new (call-next-method)))
1143 (add-to-list 'semantic-collector-per-buffer-list new
)
1145 (slot-makeunbound old
'last-completion
)
1146 (slot-makeunbound old
'last-prefix
)
1147 (slot-makeunbound old
'current-exact-match
)
1150 ;; Buffer specific collectors should flush themselves
1151 (defun semantic-collector-buffer-flush (newcache)
1152 "Flush all buffer collector objects.
1153 NEWCACHE is the new tag table, but we ignore it."
1155 (let ((l semantic-collector-per-buffer-list
))
1157 (if (car l
) (semantic-collector-flush (car l
)))
1161 (add-hook 'semantic-after-toplevel-cache-change-hook
1162 'semantic-collector-buffer-flush
)
1164 ;;; DEEP BUFFER SPECIFIC COMPLETION
1166 (defclass semantic-collector-buffer-deep
1167 (semantic-collector-buffer-abstract)
1169 "Completion engine for tags in the current buffer.
1170 When searching for a tag, uses semantic deep searche functions.
1171 Basics search only in the current buffer.")
1173 (defmethod semantic-collector-calculate-cache
1174 ((obj semantic-collector-buffer-deep
))
1175 "Calculate the completion cache for OBJ.
1176 Uses `semantic-flatten-tags-table'"
1178 ;; Must create it in SEMANTICDB find format.
1179 ;; ( ( DBTABLE TAG TAG ... ) ... )
1181 (cons semanticdb-current-table
1182 (semantic-flatten-tags-table (oref obj buffer
))))))
1184 ;;; PROJECT SPECIFIC COMPLETION
1186 (defclass semantic-collector-project-abstract
(semantic-collector-abstract)
1187 ((path :initarg
:path
1189 :documentation
"List of database tables to search.
1190 At creation time, it can be anything accepted by
1191 `semanticdb-find-translate-path' as a PATH argument.")
1193 "Root class for project wide completion engines.
1194 Uses semanticdb for searching all tags in the current project."
1198 (defclass semantic-collector-project
(semantic-collector-project-abstract)
1200 "Completion engine for tags in a project.")
1203 (defmethod semantic-collector-calculate-completions-raw
1204 ((obj semantic-collector-project
) prefix completionlist
)
1205 "Calculate the completions for prefix from completionlist."
1206 (semanticdb-find-tags-for-completion prefix
(oref obj path
)))
1208 ;;; Brutish Project search
1209 (defclass semantic-collector-project-brutish
(semantic-collector-project-abstract)
1211 "Completion engine for tags in a project.")
1213 (declare-function semanticdb-brute-deep-find-tags-for-completion
1216 (defmethod semantic-collector-calculate-completions-raw
1217 ((obj semantic-collector-project-brutish
) prefix completionlist
)
1218 "Calculate the completions for prefix from completionlist."
1219 (require 'semantic
/db-find
)
1220 (semanticdb-brute-deep-find-tags-for-completion prefix
(oref obj path
)))
1222 (defclass semantic-collector-analyze-completions
(semantic-collector-abstract)
1223 ((context :initarg
:context
1224 :type semantic-analyze-context
1225 :documentation
"An analysis context.
1226 Specifies some context location from whence completion lists will be drawn."
1228 (first-pass-completions :type list
1229 :documentation
"List of valid completion tags.
1230 This list of tags is generated when completion starts. All searches
1231 derive from this list.")
1233 "Completion engine that uses the context analyzer to provide options.
1234 The only options available for completion are those which can be logically
1235 inserted into the current context.")
1237 (defmethod semantic-collector-calculate-completions-raw
1238 ((obj semantic-collector-analyze-completions
) prefix completionlist
)
1239 "calculate the completions for prefix from completionlist."
1240 ;; if there are no completions yet, calculate them.
1241 (if (not (slot-boundp obj
'first-pass-completions
))
1242 (oset obj first-pass-completions
1243 (semantic-analyze-possible-completions (oref obj context
))))
1244 ;; search our cached completion list. make it look like a semanticdb
1246 (list (cons (save-excursion
1247 (set-buffer (oref (oref obj context
) buffer
))
1248 semanticdb-current-table
)
1249 (semantic-find-tags-for-completion
1251 (oref obj first-pass-completions
)))))
1254 ;;; ------------------------------------------------------------
1255 ;;; Tag List Display Engines
1257 ;; A typical displayor accepts a pre-determined list of completions
1258 ;; generated by a collector. This format is in semanticdb search
1259 ;; form. This vaguely standard form is a bit challenging to navigate
1260 ;; because the tags do not contain buffer info, but the file assocated
1261 ;; with the tags preceed the tag in the list.
1263 ;; Basic displayors don't care, and can strip the results.
1264 ;; Advanced highlighting displayors need to know when they need
1265 ;; to load a file so that the tag in question can be highlighted.
1267 ;; Key interface methods to a displayor are:
1268 ;; * semantic-displayor-next-action
1269 ;; * semantic-displayor-set-completions
1270 ;; * semantic-displayor-current-focus
1271 ;; * semantic-displayor-show-request
1272 ;; * semantic-displayor-scroll-request
1273 ;; * semantic-displayor-focus-request
1275 (defclass semantic-displayor-abstract
()
1276 ((table :type
(or null semanticdb-find-result-with-nil
)
1278 :protection
:protected
1279 :documentation
"List of tags this displayor is showing.")
1280 (last-prefix :type string
1281 :protection
:protected
1282 :documentation
"Prefix associated with slot `table'")
1284 "Abstract displayor baseclass.
1285 Manages the display of some number of tags.
1286 Provides the basics for a displayor, including interacting with
1287 a collector, and tracking tables of completion to display."
1290 (defmethod semantic-displayor-cleanup ((obj semantic-displayor-abstract
))
1291 "Clean up any mess this displayor may have."
1294 (defmethod semantic-displayor-next-action ((obj semantic-displayor-abstract
))
1295 "The next action to take on the minibuffer related to display."
1296 (if (and (slot-boundp obj
'last-prefix
)
1297 (string= (oref obj last-prefix
) (semantic-completion-text))
1298 (eq last-command this-command
))
1302 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-abstract
)
1304 "Set the list of tags to be completed over to TABLE."
1305 (oset obj table table
)
1306 (oset obj last-prefix prefix
))
1308 (defmethod semantic-displayor-show-request ((obj semantic-displayor-abstract
))
1309 "A request to show the current tags table."
1312 (defmethod semantic-displayor-focus-request ((obj semantic-displayor-abstract
))
1313 "A request to for the displayor to focus on some tag option."
1316 (defmethod semantic-displayor-scroll-request ((obj semantic-displayor-abstract
))
1317 "A request to for the displayor to scroll the completion list (if needed)."
1318 (scroll-other-window))
1320 (defmethod semantic-displayor-focus-previous ((obj semantic-displayor-abstract
))
1321 "Set the current focus to the previous item."
1324 (defmethod semantic-displayor-focus-next ((obj semantic-displayor-abstract
))
1325 "Set the current focus to the next item."
1328 (defmethod semantic-displayor-current-focus ((obj semantic-displayor-abstract
))
1329 "Return a single tag currently in focus.
1330 This object type doesn't do focus, so will never have a focus object."
1333 ;; Traditional displayor
1334 (defcustom semantic-completion-displayor-format-tag-function
1335 #'semantic-format-tag-name
1336 "*A Tag format function to use when showing completions."
1338 :type semantic-format-tag-custom-list
)
1340 (defclass semantic-displayor-traditional
(semantic-displayor-abstract)
1342 "Display options in *Completions* buffer.
1343 Traditional display mechanism for a list of possible completions.
1344 Completions are showin in a new buffer and listed with the ability
1345 to click on the items to aid in completion.")
1347 (defmethod semantic-displayor-show-request ((obj semantic-displayor-traditional
))
1348 "A request to show the current tags table."
1350 ;; NOTE TO SELF. Find the character to type next, and emphesize it.
1352 (with-output-to-temp-buffer "*Completions*"
1353 (display-completion-list
1354 (mapcar semantic-completion-displayor-format-tag-function
1355 (semanticdb-strip-find-results (oref obj table
))))
1359 ;;; Abstract baseclass for any displayor which supports focus
1360 (defclass semantic-displayor-focus-abstract
(semantic-displayor-abstract)
1361 ((focus :type number
1362 :protection
:protected
1363 :documentation
"A tag index from `table' which has focus.
1364 Multiple calls to the display function can choose to focus on a
1365 given tag, by highlighting its location.")
1370 "Non-nil if focusing requires a tag's buffer be in memory.")
1372 "Abstract displayor supporting `focus'.
1373 A displayor which has the ability to focus in on one tag.
1374 Focusing is a way of differentiationg between multiple tags
1375 which have the same name."
1378 (defmethod semantic-displayor-next-action ((obj semantic-displayor-focus-abstract
))
1379 "The next action to take on the minibuffer related to display."
1380 (if (and (slot-boundp obj
'last-prefix
)
1381 (string= (oref obj last-prefix
) (semantic-completion-text))
1382 (eq last-command this-command
))
1384 (slot-boundp obj
'focus
)
1385 (slot-boundp obj
'table
)
1386 (<= (semanticdb-find-result-length (oref obj table
))
1387 (1+ (oref obj focus
))))
1388 ;; We are at the end of the focus road.
1390 ;; Focus on some item.
1394 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-focus-abstract
)
1396 "Set the list of tags to be completed over to TABLE."
1398 (slot-makeunbound obj
'focus
))
1400 (defmethod semantic-displayor-focus-previous ((obj semantic-displayor-focus-abstract
))
1401 "Set the current focus to the previous item.
1402 Not meaningful return value."
1403 (when (and (slot-boundp obj
'table
) (oref obj table
))
1404 (with-slots (table) obj
1405 (if (or (not (slot-boundp obj
'focus
))
1406 (<= (oref obj focus
) 0))
1407 (oset obj focus
(1- (semanticdb-find-result-length table
)))
1408 (oset obj focus
(1- (oref obj focus
)))
1412 (defmethod semantic-displayor-focus-next ((obj semantic-displayor-focus-abstract
))
1413 "Set the current focus to the next item.
1414 Not meaningful return value."
1415 (when (and (slot-boundp obj
'table
) (oref obj table
))
1416 (with-slots (table) obj
1417 (if (not (slot-boundp obj
'focus
))
1419 (oset obj focus
(1+ (oref obj focus
)))
1421 (if (<= (semanticdb-find-result-length table
) (oref obj focus
))
1425 (defmethod semantic-displayor-focus-tag ((obj semantic-displayor-focus-abstract
))
1426 "Return the next tag OBJ should focus on."
1427 (when (and (slot-boundp obj
'table
) (oref obj table
))
1428 (with-slots (table) obj
1429 (semanticdb-find-result-nth table
(oref obj focus
)))))
1431 (defmethod semantic-displayor-current-focus ((obj semantic-displayor-focus-abstract
))
1432 "Return the tag currently in focus, or call parent method."
1433 (if (and (slot-boundp obj
'focus
)
1434 (slot-boundp obj
'table
)
1435 ;; Only return the current focus IFF the minibuffer reflects
1436 ;; the list this focus was derived from.
1437 (slot-boundp obj
'last-prefix
)
1438 (string= (semantic-completion-text) (oref obj last-prefix
))
1441 (if (oref obj find-file-focus
)
1442 (semanticdb-find-result-nth-in-buffer (oref obj table
) (oref obj focus
))
1443 ;; result-nth returns a cons with car being the tag, and cdr the
1445 (car (semanticdb-find-result-nth (oref obj table
) (oref obj focus
))))
1447 (call-next-method)))
1449 ;;; Simple displayor which performs traditional display completion,
1450 ;; and also focuses with highlighting.
1451 (defclass semantic-displayor-traditional-with-focus-highlight
1452 (semantic-displayor-focus-abstract semantic-displayor-traditional
)
1453 ((find-file-focus :initform t
))
1454 "Display completions in *Completions* buffer, with focus highlight.
1455 A traditional displayor which can focus on a tag by showing it.
1456 Same as `semantic-displayor-traditional', but with selection between
1457 multiple tags with the same name done by 'focusing' on the source
1458 location of the different tags to differentiate them.")
1460 (defmethod semantic-displayor-focus-request
1461 ((obj semantic-displayor-traditional-with-focus-highlight
))
1462 "Focus in on possible tag completions.
1463 Focus is performed by cycling through the tags and highlighting
1464 one in the source buffer."
1465 (let* ((tablelength (semanticdb-find-result-length (oref obj table
)))
1466 (focus (semantic-displayor-focus-tag obj
))
1469 (rtable (cdr focus
))
1471 (nt (semanticdb-normalize-one-tag rtable rtag
))
1475 ;; If we fail to normalize, resete.
1476 (when (not tag
) (setq table rtable tag rtag
))
1478 (let ((buf (or (semantic-tag-buffer tag
)
1479 (and table
(semanticdb-get-buffer table
)))))
1480 ;; If no buffer is provided, then we can make up a summary buffer.
1483 (set-buffer (get-buffer-create "*Completion Focus*"))
1485 (insert "Focus on tag: \n")
1486 (insert (semantic-format-tag-summarize tag nil t
) "\n\n")
1488 (insert "From table: \n")
1489 (insert (object-name table
) "\n\n"))
1491 (insert "In buffer: \n\n")
1492 (insert (format "%S" buf
)))
1493 (setq buf
(current-buffer))))
1494 ;; Show the tag in the buffer.
1495 (if (get-buffer-window buf
)
1496 (select-window (get-buffer-window buf
))
1497 (switch-to-buffer-other-window buf t
)
1498 (select-window (get-buffer-window buf
)))
1499 ;; Now do some positioning
1501 (if (semantic-tag-with-position-p tag
)
1502 ;; Full tag positional information available
1504 (goto-char (semantic-tag-start tag
))
1505 ;; This avoids a dangerous problem if we just loaded a tag
1506 ;; from a file, but the original position was not updated
1507 ;; in the TAG variable we are currently using.
1508 (semantic-momentary-highlight-tag (semantic-current-tag))
1510 (select-window (minibuffer-window)))
1511 ;; Calculate text difference between contents and the focus item.
1512 (let* ((mbc (semantic-completion-text))
1513 (ftn (semantic-tag-name tag
))
1514 (diff (substring ftn
(length mbc
))))
1515 (semantic-completion-message
1516 (format "%s [%d of %d matches]" diff
(1+ (oref obj focus
)) tablelength
)))
1520 ;;; Tooltip completion lister
1522 ;; Written and contributed by Masatake YAMATO <jet@gyve.org>
1524 ;; Modified by Eric Ludlam for
1525 ;; * Safe compatibility for tooltip free systems.
1526 ;; * Don't use 'avoid package for tooltip positioning.
1528 (defclass semantic-displayor-tooltip
(semantic-displayor-traditional)
1529 ((max-tags :type integer
1534 "Max number of tags displayed on tooltip at once.
1535 If `force-show' is 1, this value is ignored with typing tab or space twice continuously.
1536 if `force-show' is 0, this value is always ignored.")
1537 (force-show :type integer
1538 :initarg
:force-show
1540 :custom
(choice (const
1541 :tag
"Show when double typing"
1547 :tag
"Show if the number of tags is less than `max-tags'."
1550 "Control the behavior of the number of tags is greater than `max-tags'.
1551 -1 means tags are never shown.
1552 0 means the tags are always shown.
1553 1 means tags are shown if space or tab is typed twice continuously.")
1554 (typing-count :type integer
1557 "Counter holding how many times the user types space or tab continuously before showing tags.")
1558 (shown :type boolean
1561 "Flag representing whether tags is shown once or not.")
1563 "Display completions options in a tooltip.
1564 Display mechanism using tooltip for a list of possible completions.")
1566 (defmethod initialize-instance :AFTER
((obj semantic-displayor-tooltip
) &rest args
)
1567 "Make sure we have tooltips required."
1573 (defmethod semantic-displayor-show-request ((obj semantic-displayor-tooltip
))
1574 "A request to show the current tags table."
1575 (if (or (not (featurep 'tooltip
)) (not tooltip-mode
))
1576 ;; If we cannot use tooltips, then go to the normal mode with
1577 ;; a traditional completion buffer.
1579 (let* ((tablelong (semanticdb-strip-find-results (oref obj table
)))
1580 (table (semantic-unique-tag-table-by-name tablelong
))
1581 (l (mapcar semantic-completion-displayor-format-tag-function table
))
1583 (typing-count (oref obj typing-count
))
1584 (force-show (oref obj force-show
))
1585 (matchtxt (semantic-completion-text))
1587 (if (or (oref obj shown
)
1588 (< ll
(oref obj max-tags
))
1589 (and (<= 0 force-show
)
1590 (< (1- force-show
) typing-count
)))
1592 (oset obj typing-count
0)
1595 ;; We Have only one possible match. There could be two cases.
1596 ;; 1) input text != single match.
1598 ;; 2) input text == single match.
1599 ;; --> Complain about it, but still show the match.
1600 (if (string= matchtxt
(semantic-tag-name (car table
)))
1601 (setq msg
(concat "[COMPLETE]\n" (car l
)))
1603 ;; Create the long message.
1604 (setq msg
(mapconcat 'identity l
"\n"))
1605 ;; If there is nothing, say so!
1606 (if (eq 0 (length msg
))
1607 (setq msg
"[NO MATCH]")))
1608 (semantic-displayor-tooltip-show msg
))
1609 ;; The typing count determines if the user REALLY REALLY
1610 ;; wanted to show that much stuff. Only increment
1611 ;; if the current command is a completion command.
1612 (if (and (stringp (this-command-keys))
1613 (string= (this-command-keys) "\C-i"))
1614 (oset obj typing-count
(1+ typing-count
)))
1615 ;; At this point, we know we have too many items.
1616 ;; Lets be brave, and truncate l
1617 (setcdr (nthcdr (oref obj max-tags
) l
) nil
)
1618 (setq msg
(mapconcat 'identity l
"\n"))
1621 (semantic-displayor-tooltip-show (concat msg
"\n...")))
1623 (semantic-displayor-tooltip-show (concat msg
"\n(TAB for more)")))
1629 (if (fboundp 'window-inside-edges
)
1631 (defalias 'semantic-displayor-window-edges
1632 'window-inside-edges
)
1634 (defalias 'semantic-displayor-window-edges
1638 (defun semantic-displayor-point-position ()
1639 "Return the location of POINT as positioned on the selected frame.
1640 Return a cons cell (X . Y)"
1641 (let* ((frame (selected-frame))
1642 (left (frame-parameter frame
'left
))
1643 (top (frame-parameter frame
'top
))
1644 (point-pix-pos (posn-x-y (posn-at-point)))
1645 (edges (window-inside-pixel-edges (selected-window))))
1646 (cons (+ (car point-pix-pos
) (car edges
) left
)
1647 (+ (cdr point-pix-pos
) (cadr edges
) top
))))
1650 (defun semantic-displayor-tooltip-show (text)
1651 "Display a tooltip with TEXT near cursor."
1652 (let ((point-pix-pos (semantic-displayor-point-position))
1653 (tooltip-frame-parameters
1654 (append tooltip-frame-parameters nil
)))
1656 (cons 'left
(+ (car point-pix-pos
) (frame-char-width)))
1657 tooltip-frame-parameters
)
1659 (cons 'top
(+ (cdr point-pix-pos
) (frame-char-height)))
1660 tooltip-frame-parameters
)
1661 (tooltip-show text
)))
1663 (defmethod semantic-displayor-scroll-request ((obj semantic-displayor-tooltip
))
1664 "A request to for the displayor to scroll the completion list (if needed)."
1665 ;; Do scrolling in the tooltip.
1666 (oset obj max-tags
30)
1667 (semantic-displayor-show-request obj
)
1670 ;; End code contributed by Masatake YAMATO <jet@gyve.org>
1673 ;;; Ghost Text displayor
1675 (defclass semantic-displayor-ghost
(semantic-displayor-focus-abstract)
1677 ((ghostoverlay :type overlay
1679 "The overlay the ghost text is displayed in.")
1680 (first-show :initform t
1682 "Non nil if we have not seen our first show request.")
1684 "Cycle completions inline with ghost text.
1685 Completion displayor using ghost chars after point for focus options.
1686 Whichever completion is currently in focus will be displayed as ghost
1687 text using overlay options.")
1689 (defmethod semantic-displayor-next-action ((obj semantic-displayor-ghost
))
1690 "The next action to take on the inline completion related to display."
1691 (let ((ans (call-next-method))
1692 (table (when (slot-boundp obj
'table
)
1694 (if (and (eq ans
'displayend
)
1696 (= (semanticdb-find-result-length table
) 1)
1701 (defmethod semantic-displayor-cleanup ((obj semantic-displayor-ghost
))
1702 "Clean up any mess this displayor may have."
1703 (when (slot-boundp obj
'ghostoverlay
)
1704 (semantic-overlay-delete (oref obj ghostoverlay
)))
1707 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-ghost
)
1709 "Set the list of tags to be completed over to TABLE."
1712 (semantic-displayor-cleanup obj
)
1716 (defmethod semantic-displayor-show-request ((obj semantic-displayor-ghost
))
1717 "A request to show the current tags table."
1718 ; (if (oref obj first-show)
1720 ; (oset obj first-show nil)
1721 (semantic-displayor-focus-next obj
)
1722 (semantic-displayor-focus-request obj
)
1724 ;; Only do the traditional thing if the first show request
1725 ;; has been seen. Use the first one to start doing the ghost
1727 ; (call-next-method)
1731 (defmethod semantic-displayor-focus-request
1732 ((obj semantic-displayor-ghost
))
1733 "Focus in on possible tag completions.
1734 Focus is performed by cycling through the tags and showing a possible
1735 completion text in ghost text."
1736 (let* ((tablelength (semanticdb-find-result-length (oref obj table
)))
1737 (focus (semantic-displayor-focus-tag obj
))
1741 (semantic-completion-message "No tags to focus on.")
1742 ;; Display the focus completion as ghost text after the current
1744 (when (or (not (slot-boundp obj
'ghostoverlay
))
1745 (not (semantic-overlay-live-p (oref obj ghostoverlay
))))
1746 (oset obj ghostoverlay
1747 (semantic-make-overlay (point) (1+ (point)) (current-buffer) t
)))
1749 (let* ((lp (semantic-completion-text))
1750 (os (substring (semantic-tag-name tag
) (length lp
)))
1751 (ol (oref obj ghostoverlay
))
1754 (put-text-property 0 (length os
) 'face
'region os
)
1756 (semantic-overlay-put
1757 ol
'display
(concat os
(buffer-substring (point) (1+ (point)))))
1759 ;; Calculate text difference between contents and the focus item.
1760 (let* ((mbc (semantic-completion-text))
1761 (ftn (concat (semantic-tag-name tag
)))
1763 (put-text-property (length mbc
) (length ftn
) 'face
1765 (semantic-completion-message
1766 (format "%s [%d of %d matches]" ftn
(1+ (oref obj focus
)) tablelength
)))
1770 ;;; ------------------------------------------------------------
1771 ;;; Specific queries
1773 (defvar semantic-complete-inline-custom-type
1777 (let* ((C (intern (car class
)))
1778 (doc (documentation-property C
'variable-documentation
))
1779 (doc1 (car (split-string doc
"\n")))
1784 (eieio-build-class-alist semantic-displayor-abstract t
))
1786 "Possible options for inlince completion displayors.
1787 Use this to enable custom editing.")
1789 (defcustom semantic-complete-inline-analyzer-displayor-class
1790 'semantic-displayor-traditional
1791 "*Class for displayor to use with inline completion."
1793 :type semantic-complete-inline-custom-type
1796 (defun semantic-complete-read-tag-buffer-deep (prompt &optional
1800 "Ask for a tag by name from the current buffer.
1801 Available tags are from the current buffer, at any level.
1802 Completion options are presented in a traditional way, with highlighting
1803 to resolve same-name collisions.
1804 PROMPT is a string to prompt with.
1805 DEFAULT-TAG is a semantic tag or string to use as the default value.
1806 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
1807 HISTORY is a symbol representing a variable to store the history in."
1808 (semantic-complete-read-tag-engine
1809 (semantic-collector-buffer-deep prompt
:buffer
(current-buffer))
1810 (semantic-displayor-traditional-with-focus-highlight "simple")
1811 ;;(semantic-displayor-tooltip "simple")
1818 (defun semantic-complete-read-tag-project (prompt &optional
1822 "Ask for a tag by name from the current project.
1823 Available tags are from the current project, at the top level.
1824 Completion options are presented in a traditional way, with highlighting
1825 to resolve same-name collisions.
1826 PROMPT is a string to prompt with.
1827 DEFAULT-TAG is a semantic tag or string to use as the default value.
1828 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
1829 HISTORY is a symbol representing a variable to store the history in."
1830 (semantic-complete-read-tag-engine
1831 (semantic-collector-project-brutish prompt
1832 :buffer
(current-buffer)
1833 :path
(current-buffer)
1835 (semantic-displayor-traditional-with-focus-highlight "simple")
1842 (defun semantic-complete-inline-tag-project ()
1843 "Complete a symbol name by name from within the current project.
1844 This is similar to `semantic-complete-read-tag-project', except
1845 that the completion interaction is in the buffer where the context
1846 was calculated from.
1847 Customize `semantic-complete-inline-analyzer-displayor-class'
1848 to control how completion options are displayed.
1849 See `semantic-complete-inline-tag-engine' for details on how
1851 (let* ((collector (semantic-collector-project-brutish
1853 :buffer
(current-buffer)
1854 :path
(current-buffer)))
1855 (sbounds (semantic-ctxt-current-symbol-and-bounds))
1856 (syms (car sbounds
))
1857 (start (car (nth 2 sbounds
)))
1858 (end (cdr (nth 2 sbounds
)))
1859 (rsym (reverse syms
))
1860 (thissym (nth 1 sbounds
))
1861 (nextsym (car-safe (cdr rsym
)))
1863 (when (and thissym
(or (not (string= thissym
""))
1865 ;; Do a quick calcuation of completions.
1866 (semantic-collector-calculate-completions
1867 collector thissym nil
)
1868 ;; Get the master list
1869 (setq complst
(semanticdb-strip-find-results
1870 (semantic-collector-all-completions collector thissym
)))
1872 (setq complst
(semantic-unique-tag-table-by-name complst
))
1873 (if (or (and (= (length complst
) 1)
1874 ;; Check to see if it is the same as what is there.
1875 ;; if so, we can offer to complete.
1876 (let ((compname (semantic-tag-name (car complst
))))
1877 (not (string= compname thissym
))))
1878 (> (length complst
) 1))
1879 ;; There are several options. Do the completion.
1880 (semantic-complete-inline-tag-engine
1882 (funcall semantic-complete-inline-analyzer-displayor-class
1884 ;;(semantic-displayor-tooltip "simple")
1889 (defun semantic-complete-read-tag-analyzer (prompt &optional
1892 "Ask for a tag by name based on the current context.
1893 The function `semantic-analyze-current-context' is used to
1894 calculate the context. `semantic-analyze-possible-completions' is used
1895 to generate the list of possible completions.
1896 PROMPT is the first part of the prompt. Additional prompt
1897 is added based on the contexts full prefix.
1898 CONTEXT is the semantic analyzer context to start with.
1899 HISTORY is a symbol representing a variable to stor the history in.
1900 usually a default-tag and initial-input are available for completion
1901 prompts. these are calculated from the CONTEXT variable passed in."
1902 (if (not context
) (setq context
(semantic-analyze-current-context (point))))
1903 (let* ((syms (semantic-ctxt-current-symbol (point)))
1904 (inp (car (reverse syms
))))
1905 (setq syms
(nreverse (cdr (nreverse syms
))))
1906 (semantic-complete-read-tag-engine
1907 (semantic-collector-analyze-completions
1909 :buffer
(oref context buffer
)
1911 (semantic-displayor-traditional-with-focus-highlight "simple")
1913 (set-buffer (oref context buffer
))
1914 (goto-char (cdr (oref context bounds
)))
1915 (concat prompt
(mapconcat 'identity syms
".")
1922 (defun semantic-complete-inline-analyzer (context)
1923 "Complete a symbol name by name based on the current context.
1924 This is similar to `semantic-complete-read-tag-analyze', except
1925 that the completion interaction is in the buffer where the context
1926 was calculated from.
1927 CONTEXT is the semantic analyzer context to start with.
1928 Customize `semantic-complete-inline-analyzer-displayor-class'
1929 to control how completion options are displayed.
1931 See `semantic-complete-inline-tag-engine' for details on how
1933 (if (not context
) (setq context
(semantic-analyze-current-context (point))))
1934 (if (not context
) (error "Nothing to complete on here"))
1935 (let* ((collector (semantic-collector-analyze-completions
1937 :buffer
(oref context buffer
)
1939 (syms (semantic-ctxt-current-symbol (point)))
1940 (rsym (reverse syms
))
1941 (thissym (car rsym
))
1942 (nextsym (car-safe (cdr rsym
)))
1944 (when (and thissym
(or (not (string= thissym
""))
1946 ;; Do a quick calcuation of completions.
1947 (semantic-collector-calculate-completions
1948 collector thissym nil
)
1949 ;; Get the master list
1950 (setq complst
(semanticdb-strip-find-results
1951 (semantic-collector-all-completions collector thissym
)))
1953 (setq complst
(semantic-unique-tag-table-by-name complst
))
1954 (if (or (and (= (length complst
) 1)
1955 ;; Check to see if it is the same as what is there.
1956 ;; if so, we can offer to complete.
1957 (let ((compname (semantic-tag-name (car complst
))))
1958 (not (string= compname thissym
))))
1959 (> (length complst
) 1))
1960 ;; There are several options. Do the completion.
1961 (semantic-complete-inline-tag-engine
1963 (funcall semantic-complete-inline-analyzer-displayor-class
1965 ;;(semantic-displayor-tooltip "simple")
1966 (oref context buffer
)
1967 (car (oref context bounds
))
1968 (cdr (oref context bounds
))
1972 (defcustom semantic-complete-inline-analyzer-idle-displayor-class
1973 'semantic-displayor-ghost
1974 "*Class for displayor to use with inline completion at idle time."
1976 :type semantic-complete-inline-custom-type
1979 (defun semantic-complete-inline-analyzer-idle (context)
1980 "Complete a symbol name by name based on the current context for idle time.
1981 CONTEXT is the semantic analyzer context to start with.
1982 This function is used from `semantic-idle-completions-mode'.
1984 This is the same as `semantic-complete-inline-analyzer', except that
1985 it uses `semantic-complete-inline-analyzer-idle-displayor-class'
1986 to control how completions are displayed.
1988 See `semantic-complete-inline-tag-engine' for details on how
1990 (let ((semantic-complete-inline-analyzer-displayor-class
1991 semantic-complete-inline-analyzer-idle-displayor-class
))
1992 (semantic-complete-inline-analyzer context
)
1996 ;;; ------------------------------------------------------------
1999 (defun semantic-complete-test ()
2000 "Test completion mechanisms."
2003 (semantic-format-tag-prototype
2004 (semantic-complete-read-tag-project "Symbol: ")
2008 (defun semantic-complete-jump-local ()
2009 "Jump to a semantic symbol."
2011 (let ((tag (semantic-complete-read-tag-buffer-deep "Symbol: ")))
2012 (when (semantic-tag-p tag
)
2014 (goto-char (semantic-tag-start tag
))
2015 (semantic-momentary-highlight-tag tag
)
2017 (semantic-tag-class tag
)
2018 (semantic-tag-name tag
)))))
2021 (defun semantic-complete-jump ()
2022 "Jump to a semantic symbol."
2024 (let* ((tag (semantic-complete-read-tag-project "Symbol: ")))
2025 (when (semantic-tag-p tag
)
2027 (semantic-go-to-tag tag
)
2028 (switch-to-buffer (current-buffer))
2029 (semantic-momentary-highlight-tag tag
)
2031 (semantic-tag-class tag
)
2032 (semantic-tag-name tag
)))))
2035 (defun semantic-complete-analyze-and-replace ()
2036 "Perform prompt completion to do in buffer completion.
2037 `semantic-analyze-possible-completions' is used to determine the
2039 The minibuffer is used to perform the completion.
2040 The result is inserted as a replacement of the text that was there."
2042 (let* ((c (semantic-analyze-current-context (point)))
2043 (tag (save-excursion (semantic-complete-read-tag-analyzer "" c
))))
2044 ;; Take tag, and replace context bound with its name.
2045 (goto-char (car (oref c bounds
)))
2046 (delete-region (point) (cdr (oref c bounds
)))
2047 (insert (semantic-tag-name tag
))
2048 (message "%S" (semantic-format-tag-summarize tag
))))
2051 (defun semantic-complete-analyze-inline ()
2052 "Perform prompt completion to do in buffer completion.
2053 `semantic-analyze-possible-completions' is used to determine the
2055 The function returns immediately, leaving the buffer in a mode that
2056 will perform the completion.
2057 Configure `semantic-complete-inline-analyzer-displayor-class' to change
2058 how completion options are displayed."
2060 ;; Only do this if we are not already completing something.
2061 (if (not (semantic-completion-inline-active-p))
2062 (semantic-complete-inline-analyzer
2063 (semantic-analyze-current-context (point))))
2064 ;; Report a message if things didn't startup.
2065 (if (and (interactive-p)
2066 (not (semantic-completion-inline-active-p)))
2067 (message "Inline completion not needed.")
2068 ;; Since this is most likely bound to something, and not used
2069 ;; at idle time, throw in a TAB for good measure.
2070 (semantic-complete-inline-TAB)
2074 (defun semantic-complete-analyze-inline-idle ()
2075 "Perform prompt completion to do in buffer completion.
2076 `semantic-analyze-possible-completions' is used to determine the
2078 The function returns immediately, leaving the buffer in a mode that
2079 will perform the completion.
2080 Configure `semantic-complete-inline-analyzer-idle-displayor-class'
2081 to change how completion options are displayed."
2083 ;; Only do this if we are not already completing something.
2084 (if (not (semantic-completion-inline-active-p))
2085 (semantic-complete-inline-analyzer-idle
2086 (semantic-analyze-current-context (point))))
2087 ;; Report a message if things didn't startup.
2088 (if (and (interactive-p)
2089 (not (semantic-completion-inline-active-p)))
2090 (message "Inline completion not needed."))
2094 (defun semantic-complete-self-insert (arg)
2095 "Like `self-insert-command', but does completion afterwards.
2096 ARG is passed to `self-insert-command'. If ARG is nil,
2097 use `semantic-complete-analyze-inline' to complete."
2099 ;; If we are already in a completion scenario, exit now, and then start over.
2100 (semantic-complete-inline-exit)
2103 (self-insert-command arg
)
2105 ;; Prepare for doing completion, but exit quickly if there is keyboard
2107 (when (and (not (semantic-exit-on-input 'csi
2108 (semantic-fetch-tags)
2109 (semantic-throw-on-input 'csi
)
2112 (not (semantic-exit-on-input 'csi
2113 (semantic-analyze-current-context)
2114 (semantic-throw-on-input 'csi
)
2117 (semantic-complete-analyze-inline)
2118 ;; Ignore errors. Seems likely that we'll get some once in a while.
2122 ;; @TODO - I can't find where this fcn is used. Delete?
2125 ;(defun semantic-complete-inline-project ()
2126 ; "Perform inline completion for any symbol in the current project.
2127 ;`semantic-analyze-possible-completions' is used to determine the
2129 ;The function returns immediately, leaving the buffer in a mode that
2130 ;will perform the completion."
2132 ; ;; Only do this if we are not already completing something.
2133 ; (if (not (semantic-completion-inline-active-p))
2134 ; (semantic-complete-inline-tag-project))
2135 ; ;; Report a message if things didn't startup.
2136 ; (if (and (interactive-p)
2137 ; (not (semantic-completion-inline-active-p)))
2138 ; (message "Inline completion not needed."))
2142 (provide 'semantic
/complete
)
2145 ;; generated-autoload-file: "loaddefs.el"
2146 ;; generated-autoload-feature: semantic/loaddefs
2147 ;; generated-autoload-load-name: "semantic/complete"
2150 ;;; semantic/complete.el ends here