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
112 (require 'semantic
/tag-file
)
113 (require 'semantic
/find
)
114 (require 'semantic
/analyze
)
115 (require 'semantic
/format
)
116 (require 'semantic
/ctxt
)
117 ;; Keep semanticdb optional.
118 ;; (eval-when-compile
119 ;; (require 'semantic/db)
120 ;; (require 'semantic/db-find))
121 (require 'semantic
/decorate
)
122 (require 'semantic
/analyze
/complete
)
127 ;; Tooltip not available in older emacsen.
136 (if (fboundp 'minibuffer-contents
)
137 (eval-and-compile (defalias 'semantic-minibuffer-contents
'minibuffer-contents
))
138 (eval-and-compile (defalias 'semantic-minibuffer-contents
'buffer-string
)))
139 (if (fboundp 'delete-minibuffer-contents
)
140 (eval-and-compile (defalias 'semantic-delete-minibuffer-contents
'delete-minibuffer-contents
))
141 (eval-and-compile (defalias 'semantic-delete-minibuffer-contents
'erase-buffer
)))
143 (defvar semantic-complete-inline-overlay nil
144 "The overlay currently active while completing inline.")
146 (defun semantic-completion-inline-active-p ()
147 "Non-nil if inline completion is active."
148 (when (and semantic-complete-inline-overlay
149 (not (semantic-overlay-live-p semantic-complete-inline-overlay
)))
150 (semantic-overlay-delete semantic-complete-inline-overlay
)
151 (setq semantic-complete-inline-overlay nil
))
152 semantic-complete-inline-overlay
)
154 ;;; ------------------------------------------------------------
155 ;;; MINIBUFFER or INLINE utils
157 (defun semantic-completion-text ()
158 "Return the text that is currently in the completion buffer.
159 For a minibuffer prompt, this is the minibuffer text.
160 For inline completion, this is the text wrapped in the inline completion
162 (if semantic-complete-inline-overlay
163 (semantic-complete-inline-text)
164 (semantic-minibuffer-contents)))
166 (defun semantic-completion-delete-text ()
167 "Delete the text that is actively being completed.
168 Presumably if you call this you will insert something new there."
169 (if semantic-complete-inline-overlay
170 (semantic-complete-inline-delete-text)
171 (semantic-delete-minibuffer-contents)))
173 (defun semantic-completion-message (fmt &rest args
)
174 "Display the string FMT formatted with ARGS at the end of the minibuffer."
175 (if semantic-complete-inline-overlay
176 (apply 'message fmt args
)
177 (message (concat (buffer-string) (apply 'format fmt args
)))))
179 ;;; ------------------------------------------------------------
180 ;;; MINIBUFFER: Option Selection harnesses
182 (defvar semantic-completion-collector-engine nil
183 "The tag collector for the current completion operation.
184 Value should be an object of a subclass of
185 `semantic-completion-engine-abstract'.")
187 (defvar semantic-completion-display-engine nil
188 "The tag display engine for the current completion operation.
189 Value should be a ... what?")
191 (defvar semantic-complete-key-map
192 (let ((km (make-sparse-keymap)))
193 (define-key km
" " 'semantic-complete-complete-space
)
194 (define-key km
"\t" 'semantic-complete-complete-tab
)
195 (define-key km
"\C-m" 'semantic-complete-done
)
196 (define-key km
"\C-g" 'abort-recursive-edit
)
197 (define-key km
"\M-n" 'next-history-element
)
198 (define-key km
"\M-p" 'previous-history-element
)
199 (define-key km
"\C-n" 'next-history-element
)
200 (define-key km
"\C-p" 'previous-history-element
)
201 ;; Add history navigation
203 "Keymap used while completing across a list of tags.")
205 (defvar semantic-completion-default-history nil
206 "Default history variable for any unhistoried prompt.
207 Keeps STRINGS only in the history.")
210 (defun semantic-complete-read-tag-engine (collector displayor prompt
211 default-tag initial-input
213 "Read a semantic tag, and return a tag for the selection.
214 Argument COLLECTOR is an object which can be used to to calculate
215 a list of possible hits. See `semantic-completion-collector-engine'
216 for details on COLLECTOR.
217 Argumeng DISPLAYOR is an object used to display a list of possible
218 completions for a given prefix. See`semantic-completion-display-engine'
219 for details on DISPLAYOR.
220 PROMPT is a string to prompt with.
221 DEFAULT-TAG is a semantic tag or string to use as the default value.
222 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
223 HISTORY is a symbol representing a variable to story the history in."
224 (let* ((semantic-completion-collector-engine collector
)
225 (semantic-completion-display-engine displayor
)
226 (semantic-complete-active-default nil
)
227 (semantic-complete-current-matched-tag nil
)
228 (default-as-tag (semantic-complete-default-to-tag default-tag
))
229 (default-as-string (when (semantic-tag-p default-as-tag
)
230 (semantic-tag-name default-as-tag
)))
233 (when default-as-string
234 ;; Add this to the prompt.
236 ;; I really want to add a lookup of the symbol in those
237 ;; tags available to the collector and only add it if it
238 ;; is available as a possibility, but I'm too lazy right
242 ;; @todo - move from () to into the editable area
243 (if (string-match ":" prompt
)
245 (substring prompt
0 (match-beginning 0))
246 " (" default-as-string
")"
247 (substring prompt
(match-beginning 0))))
248 (setq prompt
(concat prompt
" (" default-as-string
"): "))))
250 ;; Perform the Completion
253 (read-from-minibuffer prompt
255 semantic-complete-key-map
258 'semantic-completion-default-history
)
260 (semantic-collector-cleanup semantic-completion-collector-engine
)
261 (semantic-displayor-cleanup semantic-completion-display-engine
)
264 ;; Extract the tag from the completion machinery.
266 semantic-complete-current-matched-tag
270 ;;; Util for basic completion prompts
273 (defvar semantic-complete-active-default nil
274 "The current default tag calculated for this prompt.")
276 (defun semantic-complete-default-to-tag (default)
277 "Convert a calculated or passed in DEFAULT into a tag."
278 (if (semantic-tag-p default
)
279 ;; Just return what was passed in.
280 (setq semantic-complete-active-default default
)
281 ;; If none was passed in, guess.
283 (setq default
(semantic-ctxt-current-thing)))
287 ;; Turn default into something useful.
290 ;; Semantic-ctxt-current-symbol will return a list of
291 ;; strings. Technically, we should use the analyzer to
292 ;; fully extract what we need, but for now, just grab the
294 ((and (listp default
) (stringp (car default
)))
299 (symbol-name default
))
301 (signal 'wrong-type-argument
302 (list default
'semantic-tag-p
)))))
304 ;; Now that we have that symbol string, look it up using the active
305 ;; collector. If we get a match, use it.
307 (semantic-collector-calculate-completions
308 semantic-completion-collector-engine
310 ;; Do we have the perfect match???
311 (let ((ml (semantic-collector-current-exact-match
312 semantic-completion-collector-engine
)))
314 ;; We don't care about uniqueness. Just guess for convenience
315 (setq tag
(semanticdb-find-result-nth-in-buffer ml
0))))
317 (setq semantic-complete-active-default tag
)
318 ;; Return it.. .whatever it may be
322 ;;; Prompt Return Value
324 ;; Getting a return value out of this completion prompt is a bit
325 ;; challenging. The read command returns the string typed in.
326 ;; We need to convert this into a valid tag. We can exit the minibuffer
327 ;; for different reasons. If we purposely exit, we must make sure
328 ;; the focused tag is calculated... preferably once.
329 (defvar semantic-complete-current-matched-tag nil
330 "Variable used to pass the tags being matched to the prompt.")
332 ;; semantic-displayor-focus-abstract-child-p is part of the
333 ;; semantic-displayor-focus-abstract class, defined later in this
335 (declare-function semantic-displayor-focus-abstract-child-p
"semantic/complete")
337 (defun semantic-complete-current-match ()
338 "Calculate a match from the current completion environment.
339 Save this in our completion variable. Make sure that variable
340 is cleared if any other keypress is made.
342 tag - a single tag that has been matched.
343 string - a message to show in the minibuffer."
344 ;; Query the environment for an active completion.
345 (let ((collector semantic-completion-collector-engine
)
346 (displayor semantic-completion-display-engine
)
347 (contents (semantic-completion-text))
350 (if (string= contents
"")
351 ;; The user wants the defaults!
352 (setq answer semantic-complete-active-default
)
353 ;; This forces a full calculation of completion on CR.
355 (semantic-collector-calculate-completions collector contents nil
))
356 (semantic-complete-try-completion)
358 ;; Input match displayor focus entry
359 ((setq answer
(semantic-displayor-current-focus displayor
))
360 ;; We have answer, continue
362 ;; One match from the collector
363 ((setq matchlist
(semantic-collector-current-exact-match collector
))
364 (if (= (semanticdb-find-result-length matchlist
) 1)
365 (setq answer
(semanticdb-find-result-nth-in-buffer matchlist
0))
366 (if (semantic-displayor-focus-abstract-child-p displayor
)
367 ;; For focusing displayors, we can claim this is
368 ;; not unique. Multiple focuses can choose the correct
370 (setq answer
"Not Unique")
371 ;; If we don't have a focusing displayor, we need to do something
372 ;; graceful. First, see if all the matches have the same name.
374 (firstname (semantic-tag-name
376 (semanticdb-find-result-nth matchlist
0)))
379 (max (semanticdb-find-result-length matchlist
)))
380 (while (and allsame
(< cnt max
))
385 (semanticdb-find-result-nth matchlist cnt
)))))
389 ;; Now we know if they are all the same. If they are, just
390 ;; accept the first, otherwise complain.
392 (setq answer
(semanticdb-find-result-nth-in-buffer
394 (setq answer
"Not Unique"))
398 (setq answer
"No Match")))
400 ;; Set it into our completion target.
401 (when (semantic-tag-p answer
)
402 (setq semantic-complete-current-matched-tag answer
)
403 ;; Make sure it is up to date by clearing it if the user dares
404 ;; to touch the keyboard.
405 (add-hook 'pre-command-hook
406 (lambda () (setq semantic-complete-current-matched-tag nil
)))
415 ;; Keys are bound to to perform completion using our mechanisms.
416 ;; Do that work here.
417 (defun semantic-complete-done ()
418 "Accept the current input."
420 (let ((ans (semantic-complete-current-match)))
422 (semantic-completion-message (concat " [" ans
"]"))
426 (defun semantic-complete-complete-space ()
427 "Complete the partial input in the minibuffer."
429 (semantic-complete-do-completion t
))
431 (defun semantic-complete-complete-tab ()
432 "Complete the partial input in the minibuffer as far as possible."
434 (semantic-complete-do-completion))
436 ;;; Completion Functions
438 ;; Thees routines are functional entry points to performing completion.
440 (defun semantic-complete-hack-word-boundaries (original new
)
441 "Return a string to use for completion.
442 ORIGINAL is the text in the minibuffer.
443 NEW is the new text to insert into the minibuffer.
444 Within the difference bounds of ORIGINAL and NEW, shorten NEW
445 to the nearest word boundary, and return that."
447 (let* ((diff (substring new
(length original
)))
448 (end (string-match "\\>" diff
))
449 (start (string-match "\\<" diff
)))
451 ((and start
(> start
0))
452 ;; If start is greater than 0, include only the new
454 (concat original
(substring diff
0 start
)))
456 (concat original
(substring diff
0 end
)))
459 (defun semantic-complete-try-completion (&optional partial
)
460 "Try a completion for the current minibuffer.
461 If PARTIAL, do partial completion stopping at spaces."
462 (let ((comp (semantic-collector-try-completion
463 semantic-completion-collector-engine
464 (semantic-completion-text))))
467 (semantic-completion-message " [No Match]")
471 (if (string= (semantic-completion-text) comp
)
473 ;; Minibuffer isn't changing AND the text is not unique.
474 ;; Test for partial completion over a word separator character.
475 ;; If there is one available, use that so that SPC can
476 ;; act like a SPC insert key.
477 (let ((newcomp (semantic-collector-current-whitespace-completion
478 semantic-completion-collector-engine
)))
480 (semantic-completion-delete-text)
484 (let ((orig (semantic-completion-text)))
485 ;; For partial completion, we stop and step over
486 ;; word boundaries. Use this nifty function to do
487 ;; that calculation for us.
489 (semantic-complete-hack-word-boundaries orig comp
))))
490 ;; Do the replacement.
491 (semantic-completion-delete-text)
494 ((and (listp comp
) (semantic-tag-p (car comp
)))
495 (unless (string= (semantic-completion-text)
496 (semantic-tag-name (car comp
)))
497 ;; A fully unique completion was available.
498 (semantic-completion-delete-text)
499 (insert (semantic-tag-name (car comp
))))
500 ;; The match is complete
501 (if (= (length comp
) 1)
502 (semantic-completion-message " [Complete]")
503 (semantic-completion-message " [Complete, but not unique]"))
507 (defun semantic-complete-do-completion (&optional partial inline
)
508 "Do a completion for the current minibuffer.
509 If PARTIAL, do partial completion stopping at spaces.
510 if INLINE, then completion is happening inline in a buffer."
511 (let* ((collector semantic-completion-collector-engine
)
512 (displayor semantic-completion-display-engine
)
513 (contents (semantic-completion-text))
517 (semantic-collector-calculate-completions collector contents partial
))
518 (let* ((na (semantic-complete-next-action partial
)))
520 ;; We're all done, but only from a very specific
521 ;; area of completion.
523 (semantic-completion-message " [Complete]")
525 ;; Perform completion
526 ((or (eq na
'complete
)
527 (eq na
'complete-whitespace
))
528 (semantic-complete-try-completion partial
)
529 (setq ans
'complete
))
530 ;; We need to display the completions.
531 ;; Set the completions into the display engine
532 ((or (eq na
'display
) (eq na
'displayend
))
533 (semantic-displayor-set-completions
536 (and (not (eq na
'displayend
))
537 (semantic-collector-current-exact-match collector
))
538 (semantic-collector-all-completions collector contents
))
540 ;; Ask the displayor to display them.
541 (semantic-displayor-show-request displayor
))
543 (semantic-displayor-scroll-request displayor
)
546 (semantic-displayor-focus-next displayor
)
547 (semantic-displayor-focus-request displayor
)
550 (semantic-completion-message " [No Match]"))
555 ;;; ------------------------------------------------------------
556 ;;; INLINE: tag completion harness
558 ;; Unlike the minibuffer, there is no mode nor other traditional
559 ;; means of reading user commands in completion mode. Instead
560 ;; we use a pre-command-hook to inset in our commands, and to
561 ;; push ourselves out of this mode on alternate keypresses.
562 (defvar semantic-complete-inline-map
563 (let ((km (make-sparse-keymap)))
564 (define-key km
"\C-i" 'semantic-complete-inline-TAB
)
565 (define-key km
"\M-p" 'semantic-complete-inline-up
)
566 (define-key km
"\M-n" 'semantic-complete-inline-down
)
567 (define-key km
"\C-m" 'semantic-complete-inline-done
)
568 (define-key km
"\C-\M-c" 'semantic-complete-inline-exit
)
569 (define-key km
"\C-g" 'semantic-complete-inline-quit
)
571 (lambda () (interactive)
572 (describe-variable 'semantic-complete-inline-map
)))
574 "Keymap used while performing Semantic inline completion.
575 \\{semantic-complete-inline-map}")
577 (defface semantic-complete-inline-face
578 '((((class color
) (background dark
))
579 (:underline
"yellow"))
580 (((class color
) (background light
))
581 (:underline
"brown")))
582 "*Face used to show the region being completed inline.
583 The face is used in `semantic-complete-inline-tag-engine'."
584 :group
'semantic-faces
)
586 (defun semantic-complete-inline-text ()
587 "Return the text that is being completed inline.
588 Similar to `minibuffer-contents' when completing in the minibuffer."
589 (let ((s (semantic-overlay-start semantic-complete-inline-overlay
))
590 (e (semantic-overlay-end semantic-complete-inline-overlay
)))
593 (buffer-substring-no-properties s e
))))
595 (defun semantic-complete-inline-delete-text ()
596 "Delete the text currently being completed in the current buffer."
598 (semantic-overlay-start semantic-complete-inline-overlay
)
599 (semantic-overlay-end semantic-complete-inline-overlay
)))
601 (defun semantic-complete-inline-done ()
602 "This completion thing is DONE, OR, insert a newline."
604 (let* ((displayor semantic-completion-display-engine
)
605 (tag (semantic-displayor-current-focus displayor
)))
607 (let ((txt (semantic-completion-text)))
608 (insert (substring (semantic-tag-name tag
)
610 (semantic-complete-inline-exit))
612 ;; Get whatever binding RET usually has.
615 (lookup-key (current-active-maps) (this-command-keys))
617 ;; I don't know why, but for some reason the above
618 ;; throws an error sometimes.
619 (lookup-key (current-global-map) (this-command-keys))
625 (defun semantic-complete-inline-quit ()
626 "Quit an inline edit."
628 (semantic-complete-inline-exit)
631 (defun semantic-complete-inline-exit ()
632 "Exit inline completion mode."
634 ;; Remove this hook FIRST!
635 (remove-hook 'pre-command-hook
'semantic-complete-pre-command-hook
)
639 (when semantic-completion-collector-engine
640 (semantic-collector-cleanup semantic-completion-collector-engine
))
641 (when semantic-completion-display-engine
642 (semantic-displayor-cleanup semantic-completion-display-engine
))
644 (when semantic-complete-inline-overlay
645 (let ((wc (semantic-overlay-get semantic-complete-inline-overlay
646 'window-config-start
))
647 (buf (semantic-overlay-buffer semantic-complete-inline-overlay
))
649 (semantic-overlay-delete semantic-complete-inline-overlay
)
650 (setq semantic-complete-inline-overlay nil
)
651 ;; DONT restore the window configuration if we just
653 (when (eq buf
(current-buffer))
654 (set-window-configuration wc
))
657 (setq semantic-completion-collector-engine nil
658 semantic-completion-display-engine nil
))
661 ;; Remove this hook LAST!!!
662 ;; This will force us back through this function if there was
663 ;; some sort of error above.
664 (remove-hook 'post-command-hook
'semantic-complete-post-command-hook
)
666 ;;(message "Exiting inline completion.")
669 (defun semantic-complete-pre-command-hook ()
670 "Used to redefine what commands are being run while completing.
671 When installed as a `pre-command-hook' the special keymap
672 `semantic-complete-inline-map' is queried to replace commands normally run.
673 Commands which edit what is in the region of interest operate normally.
674 Commands which would take us out of the region of interest, or our
675 quit hook, will exit this completion mode."
676 (let ((fcn (lookup-key semantic-complete-inline-map
677 (this-command-keys) nil
)))
678 (cond ((commandp fcn
)
679 (setq this-command fcn
))
683 (defun semantic-complete-post-command-hook ()
684 "Used to determine if we need to exit inline completion mode.
685 If completion mode is active, check to see if we are within
686 the bounds of `semantic-complete-inline-overlay', or within
687 a reasonable distance."
689 ;; Exit if something bad happened.
690 (if (not semantic-complete-inline-overlay
)
692 ;;(message "Inline Hook installed, but overlay deleted.")
693 (semantic-complete-inline-exit))
694 ;; Exit if commands caused us to exit the area of interest
695 (let ((s (semantic-overlay-start semantic-complete-inline-overlay
))
696 (e (semantic-overlay-end semantic-complete-inline-overlay
))
697 (b (semantic-overlay-buffer semantic-complete-inline-overlay
))
701 ;; EXIT when we are no longer in a good place.
702 ((or (not (eq b
(current-buffer)))
705 ;;(message "Exit: %S %S %S" s e (point))
706 (semantic-complete-inline-exit)
708 ;; Exit if the user typed in a character that is not part
709 ;; of the symbol being completed.
710 ((and (setq txt
(semantic-completion-text))
711 (not (string= txt
""))
715 (not (looking-at "\\(\\w\\|\\s_\\)")))))
716 ;;(message "Non symbol character.")
717 (semantic-complete-inline-exit))
718 ((lookup-key semantic-complete-inline-map
719 (this-command-keys) nil
)
720 ;; If the last command was one of our completion commands,
725 ;; Else, show completions now
726 (semantic-complete-inline-force-display)
729 ;; If something goes terribly wrong, clean up after ourselves.
730 (error (semantic-complete-inline-exit))))
732 (defun semantic-complete-inline-force-display ()
733 "Force the display of whatever the current completions are.
734 DO NOT CALL THIS IF THE INLINE COMPLETION ENGINE IS NOT ACTIVE."
737 (let ((collector semantic-completion-collector-engine
)
738 (displayor semantic-completion-display-engine
)
739 (contents (semantic-completion-text)))
741 (semantic-collector-calculate-completions
742 collector contents nil
)
743 (semantic-displayor-set-completions
745 (semantic-collector-all-completions collector contents
)
747 ;; Ask the displayor to display them.
748 (semantic-displayor-show-request displayor
))
750 (error (message "Bug Showing Completions: %S" e
))))
752 (defun semantic-complete-inline-tag-engine
753 (collector displayor buffer start end
)
754 "Perform completion based on semantic tags in a buffer.
755 Argument COLLECTOR is an object which can be used to to calculate
756 a list of possible hits. See `semantic-completion-collector-engine'
757 for details on COLLECTOR.
758 Argumeng DISPLAYOR is an object used to display a list of possible
759 completions for a given prefix. See`semantic-completion-display-engine'
760 for details on DISPLAYOR.
761 BUFFER is the buffer in which completion will take place.
762 START is a location for the start of the full symbol.
763 If the symbol being completed is \"foo.ba\", then START
764 is on the \"f\" character.
765 END is at the end of the current symbol being completed."
766 ;; Set us up for doing completion
767 (setq semantic-completion-collector-engine collector
768 semantic-completion-display-engine displayor
)
770 (setq semantic-complete-inline-overlay
771 (semantic-make-overlay start end buffer nil t
))
772 (semantic-overlay-put semantic-complete-inline-overlay
774 'semantic-complete-inline-face
)
775 (semantic-overlay-put semantic-complete-inline-overlay
777 (current-window-configuration))
778 ;; Install our command hooks
779 (add-hook 'pre-command-hook
'semantic-complete-pre-command-hook
)
780 (add-hook 'post-command-hook
'semantic-complete-post-command-hook
)
782 (semantic-complete-inline-force-display)
785 ;;; Inline Completion Keymap Functions
787 (defun semantic-complete-inline-TAB ()
788 "Perform inline completion."
790 (let ((cmpl (semantic-complete-do-completion nil t
)))
793 (semantic-complete-inline-force-display))
795 (semantic-complete-inline-done))
799 (defun semantic-complete-inline-down()
800 "Focus forwards through the displayor."
802 (let ((displayor semantic-completion-display-engine
))
803 (semantic-displayor-focus-next displayor
)
804 (semantic-displayor-focus-request displayor
)
807 (defun semantic-complete-inline-up ()
808 "Focus backwards through the displayor."
810 (let ((displayor semantic-completion-display-engine
))
811 (semantic-displayor-focus-previous displayor
)
812 (semantic-displayor-focus-request displayor
)
816 ;;; ------------------------------------------------------------
817 ;;; Interactions between collection and displaying
819 ;; Functional routines used to help collectors communicate with
820 ;; the current displayor, or for the previous section.
822 (defun semantic-complete-next-action (partial)
823 "Determine what the next completion action should be.
824 PARTIAL is non-nil if we are doing partial completion.
825 First, the collector can determine if we should perform a completion or not.
826 If there is nothing to complete, then the displayor determines if we are
827 to show a completion list, scroll, or perhaps do a focus (if it is capable.)
828 Expected return values are:
829 done -> We have a singular match
830 empty -> There are no matches to the current text
831 complete -> Perform a completion action
832 complete-whitespace -> Complete next whitespace type character.
833 display -> Show the list of completions
834 scroll -> The completions have been shown, and the user keeps hitting
835 the complete button. If possible, scroll the completions
836 focus -> The displayor knows how to shift focus among possible completions.
838 displayend -> Whatever options the displayor had for repeating options, there
839 are none left. Try something new."
840 (let ((ans1 (semantic-collector-next-action
841 semantic-completion-collector-engine
843 (ans2 (semantic-displayor-next-action
844 semantic-completion-display-engine
))
847 ;; No collector answer, use displayor answer.
850 ;; Displayor selection of 'scroll, 'display, or 'focus trumps
852 ((and (eq ans1
'done
) ans2
)
854 ;; Use ans1 when we have it.
860 ;;; ------------------------------------------------------------
861 ;;; Collection Engines
863 ;; Collection engines can scan tags from the current environment and
864 ;; provide lists of possible completions.
866 ;; General features of the abstract collector:
867 ;; * Cache completion lists between uses
868 ;; * Cache itself per buffer. Handle reparse hooks
870 ;; Key Interface Functions to implement:
871 ;; * semantic-collector-next-action
872 ;; * semantic-collector-calculate-completions
873 ;; * semantic-collector-try-completion
874 ;; * semantic-collector-all-completions
876 (defvar semantic-collector-per-buffer-list nil
877 "List of collectors active in this buffer.")
878 (make-variable-buffer-local 'semantic-collector-per-buffer-list
)
880 (defvar semantic-collector-list nil
881 "List of global collectors active this session.")
883 (defclass semantic-collector-abstract
()
884 ((buffer :initarg
:buffer
886 :documentation
"Originating buffer for this collector.
887 Some collectors use a given buffer as a starting place while looking up
890 :type
(or null semanticdb-find-result-with-nil
)
891 :documentation
"Cache of tags.
892 These tags are re-used during a completion session.
893 Sometimes these tags are cached between completion sessions.")
894 (last-all-completions :initarg nil
895 :type semanticdb-find-result-with-nil
896 :documentation
"Last result of `all-completions'.
897 This result can be used for refined completions as `last-prefix' gets
898 closer to a specific result.")
899 (last-prefix :type string
900 :protection
:protected
901 :documentation
"The last queried prefix.
902 This prefix can be used to cache intermediate completion offers.
903 making the action of homing in on a token faster.")
904 (last-completion :type
(or null string
)
905 :documentation
"The last calculated completion.
906 This completion is calculated and saved for future use.")
907 (last-whitespace-completion :type
(or null string
)
908 :documentation
"The last whitespace completion.
909 For partial completion, SPC will disabiguate over whitespace type
910 characters. This is the last calculated version.")
911 (current-exact-match :type list
912 :protection
:protected
913 :documentation
"The list of matched tags.
914 When tokens are matched, they are added to this list.")
916 "Root class for completion engines.
917 The baseclass provides basic functionality for interacting with
918 a completion displayor object, and tracking the current progress
922 (defmethod semantic-collector-cleanup ((obj semantic-collector-abstract
))
923 "Clean up any mess this collector may have."
926 (defmethod semantic-collector-next-action
927 ((obj semantic-collector-abstract
) partial
)
928 "What should we do next? OBJ can predict a next good action.
929 PARTIAL indicates if we are doing a partial completion."
930 (if (and (slot-boundp obj
'last-completion
)
931 (string= (semantic-completion-text) (oref obj last-completion
)))
932 (let* ((cem (semantic-collector-current-exact-match obj
))
933 (cemlen (semanticdb-find-result-length cem
))
934 (cac (semantic-collector-all-completions
935 obj
(semantic-completion-text)))
936 (caclen (semanticdb-find-result-length cac
)))
937 (cond ((and cem
(= cemlen
1)
939 (eq last-command this-command
))
940 ;; Defer to the displayor...
942 ((and cem
(= cemlen
1))
944 ((and (not cem
) (not cac
))
946 ((and partial
(semantic-collector-try-completion-whitespace
947 obj
(semantic-completion-text)))
948 'complete-whitespace
)))
951 (defmethod semantic-collector-last-prefix= ((obj semantic-collector-abstract
)
953 "Return non-nil if OBJ's prefix matches PREFIX."
954 (and (slot-boundp obj
'last-prefix
)
955 (string= (oref obj last-prefix
) last-prefix
)))
957 (defmethod semantic-collector-get-cache ((obj semantic-collector-abstract
))
958 "Get the raw cache of tags for completion.
959 Calculate the cache if there isn't one."
961 (semantic-collector-calculate-cache obj
)))
963 (defmethod semantic-collector-calculate-completions-raw
964 ((obj semantic-collector-abstract
) prefix completionlist
)
965 "Calculate the completions for prefix from completionlist.
966 Output must be in semanticdb Find result format."
967 ;; Must output in semanticdb format
968 (let ((table (save-excursion
969 (set-buffer (oref obj buffer
))
970 semanticdb-current-table
))
971 (result (semantic-find-tags-for-completion
973 ;; To do this kind of search with a pre-built completion
974 ;; list, we need to strip it first.
975 (semanticdb-strip-find-results completionlist
)))
978 (list (cons table result
)))))
980 (defmethod semantic-collector-calculate-completions
981 ((obj semantic-collector-abstract
) prefix partial
)
982 "Calculate completions for prefix as setup for other queries."
983 (let* ((case-fold-search semantic-case-fold
)
984 (same-prefix-p (semantic-collector-last-prefix= obj prefix
))
986 (if (or same-prefix-p
987 (and (slot-boundp obj
'last-prefix
)
988 (eq (compare-strings (oref obj last-prefix
) 0 nil
989 prefix
0 (length prefix
))
991 ;; New prefix is subset of old prefix
992 (oref obj last-all-completions
)
993 (semantic-collector-get-cache obj
)))
995 (answer (if same-prefix-p
997 (semantic-collector-calculate-completions-raw
998 obj prefix completionlist
))
1001 (complete-not-uniq nil
)
1003 ;;(semanticdb-find-result-test answer)
1004 (when (not same-prefix-p
)
1005 ;; Save results if it is interesting and beneficial
1006 (oset obj last-prefix prefix
)
1007 (oset obj last-all-completions answer
))
1008 ;; Now calculate the completion.
1009 (setq completion
(try-completion
1011 (semanticdb-strip-find-results answer
)))
1012 (oset obj last-whitespace-completion nil
)
1013 (oset obj current-exact-match nil
)
1014 ;; Only do this if a completion was found. Letting a nil in
1015 ;; could cause a full semanticdb search by accident.
1017 (oset obj last-completion
1019 ;; Unique match in AC. Last completion is a match.
1020 ;; Also set the current-exact-match.
1022 (oset obj current-exact-match answer
)
1024 ;; It may be complete (a symbol) but still not unique.
1025 ;; We can capture a match
1026 ((setq complete-not-uniq
1027 (semanticdb-find-tags-by-name
1030 (oset obj current-exact-match
1034 ;; Non unique match, return the string that handles
1036 (t (or completion prefix
))
1040 (defmethod semantic-collector-try-completion-whitespace
1041 ((obj semantic-collector-abstract
) prefix
)
1042 "For OBJ, do whatepsace completion based on PREFIX.
1043 This implies that if there are two completions, one matching
1044 the test \"preifx\\>\", and one not, the one matching the full
1045 word version of PREFIX will be chosen, and that text returned.
1046 This function requires that `semantic-collector-calculate-completions'
1047 has been run first."
1048 (let* ((ac (semantic-collector-all-completions obj prefix
))
1049 (matchme (concat "^" prefix
"\\>"))
1050 (compare (semanticdb-find-tags-by-name-regexp matchme ac
))
1051 (numtag (semanticdb-find-result-length compare
))
1055 (cutlen (1+ (length prefix
)))
1056 (twws (semanticdb-find-result-nth compare idx
)))
1057 ;; Is our tag with whitespace a match that has whitespace
1058 ;; after it, or just an already complete symbol?
1059 (while (and (< idx numtag
)
1060 (< (length (semantic-tag-name (car twws
))) cutlen
))
1062 twws
(semanticdb-find-result-nth compare idx
)))
1063 (when (and twws
(car-safe twws
))
1064 ;; If COMPARE has succeeded, then we should take the very
1065 ;; first match, and extend prefix by one character.
1066 (oset obj last-whitespace-completion
1067 (substring (semantic-tag-name (car twws
))
1072 (defmethod semantic-collector-current-exact-match ((obj semantic-collector-abstract
))
1073 "Return the active valid MATCH from the semantic collector.
1074 For now, just return the first element from our list of available
1075 matches. For semanticdb based results, make sure the file is loaded
1077 (when (slot-boundp obj
'current-exact-match
)
1078 (oref obj current-exact-match
)))
1080 (defmethod semantic-collector-current-whitespace-completion ((obj semantic-collector-abstract
))
1081 "Return the active whitespace completion value."
1082 (when (slot-boundp obj
'last-whitespace-completion
)
1083 (oref obj last-whitespace-completion
)))
1085 (defmethod semantic-collector-get-match ((obj semantic-collector-abstract
))
1086 "Return the active valid MATCH from the semantic collector.
1087 For now, just return the first element from our list of available
1088 matches. For semanticdb based results, make sure the file is loaded
1090 (when (slot-boundp obj
'current-exact-match
)
1091 (semanticdb-find-result-nth-in-buffer (oref obj current-exact-match
) 0)))
1093 (defmethod semantic-collector-all-completions
1094 ((obj semantic-collector-abstract
) prefix
)
1095 "For OBJ, retrieve all completions matching PREFIX.
1096 The returned list consists of all the tags currently
1098 (when (slot-boundp obj
'last-all-completions
)
1099 (oref obj last-all-completions
)))
1101 (defmethod semantic-collector-try-completion
1102 ((obj semantic-collector-abstract
) prefix
)
1103 "For OBJ, attempt to match PREFIX.
1104 See `try-completion' for details on how this works.
1105 Return nil for no match.
1106 Return a string for a partial match.
1107 For a unique match of PREFIX, return the list of all tags
1109 (if (slot-boundp obj
'last-completion
)
1110 (oref obj last-completion
)))
1112 (defmethod semantic-collector-calculate-cache
1113 ((obj semantic-collector-abstract
))
1114 "Calculate the completion cache for OBJ."
1118 (defmethod semantic-collector-flush ((this semantic-collector-abstract
))
1119 "Flush THIS collector object, clearing any caches and prefix."
1120 (oset this cache nil
)
1121 (slot-makeunbound this
'last-prefix
)
1122 (slot-makeunbound this
'last-completion
)
1123 (slot-makeunbound this
'last-all-completions
)
1124 (slot-makeunbound this
'current-exact-match
)
1129 (defclass semantic-collector-buffer-abstract
(semantic-collector-abstract)
1131 "Root class for per-buffer completion engines.
1132 These collectors track themselves on a per-buffer basis."
1135 (defmethod constructor :STATIC
((this semantic-collector-buffer-abstract
)
1136 newname
&rest fields
)
1137 "Reuse previously created objects of this type in buffer."
1139 (bl semantic-collector-per-buffer-list
))
1140 (while (and bl
(null old
))
1141 (if (eq (object-class (car bl
)) this
)
1142 (setq old
(car bl
))))
1144 (let ((new (call-next-method)))
1145 (add-to-list 'semantic-collector-per-buffer-list new
)
1147 (slot-makeunbound old
'last-completion
)
1148 (slot-makeunbound old
'last-prefix
)
1149 (slot-makeunbound old
'current-exact-match
)
1152 ;; Buffer specific collectors should flush themselves
1153 (defun semantic-collector-buffer-flush (newcache)
1154 "Flush all buffer collector objects.
1155 NEWCACHE is the new tag table, but we ignore it."
1157 (let ((l semantic-collector-per-buffer-list
))
1159 (if (car l
) (semantic-collector-flush (car l
)))
1163 (add-hook 'semantic-after-toplevel-cache-change-hook
1164 'semantic-collector-buffer-flush
)
1166 ;;; DEEP BUFFER SPECIFIC COMPLETION
1168 (defclass semantic-collector-buffer-deep
1169 (semantic-collector-buffer-abstract)
1171 "Completion engine for tags in the current buffer.
1172 When searching for a tag, uses semantic deep searche functions.
1173 Basics search only in the current buffer.")
1175 (defmethod semantic-collector-calculate-cache
1176 ((obj semantic-collector-buffer-deep
))
1177 "Calculate the completion cache for OBJ.
1178 Uses `semantic-flatten-tags-table'"
1180 ;; Must create it in SEMANTICDB find format.
1181 ;; ( ( DBTABLE TAG TAG ... ) ... )
1183 (cons semanticdb-current-table
1184 (semantic-flatten-tags-table (oref obj buffer
))))))
1186 ;;; PROJECT SPECIFIC COMPLETION
1188 (defclass semantic-collector-project-abstract
(semantic-collector-abstract)
1189 ((path :initarg
:path
1191 :documentation
"List of database tables to search.
1192 At creation time, it can be anything accepted by
1193 `semanticdb-find-translate-path' as a PATH argument.")
1195 "Root class for project wide completion engines.
1196 Uses semanticdb for searching all tags in the current project."
1200 (defclass semantic-collector-project
(semantic-collector-project-abstract)
1202 "Completion engine for tags in a project.")
1205 (defmethod semantic-collector-calculate-completions-raw
1206 ((obj semantic-collector-project
) prefix completionlist
)
1207 "Calculate the completions for prefix from completionlist."
1208 (semanticdb-find-tags-for-completion prefix
(oref obj path
)))
1210 ;;; Brutish Project search
1211 (defclass semantic-collector-project-brutish
(semantic-collector-project-abstract)
1213 "Completion engine for tags in a project.")
1215 (defmethod semantic-collector-calculate-completions-raw
1216 ((obj semantic-collector-project-brutish
) prefix completionlist
)
1217 "Calculate the completions for prefix from completionlist."
1218 (semanticdb-brute-deep-find-tags-for-completion prefix
(oref obj path
)))
1220 (defclass semantic-collector-analyze-completions
(semantic-collector-abstract)
1221 ((context :initarg
:context
1222 :type semantic-analyze-context
1223 :documentation
"An analysis context.
1224 Specifies some context location from whence completion lists will be drawn."
1226 (first-pass-completions :type list
1227 :documentation
"List of valid completion tags.
1228 This list of tags is generated when completion starts. All searches
1229 derive from this list.")
1231 "Completion engine that uses the context analyzer to provide options.
1232 The only options available for completion are those which can be logically
1233 inserted into the current context.")
1235 (defmethod semantic-collector-calculate-completions-raw
1236 ((obj semantic-collector-analyze-completions
) prefix completionlist
)
1237 "calculate the completions for prefix from completionlist."
1238 ;; if there are no completions yet, calculate them.
1239 (if (not (slot-boundp obj
'first-pass-completions
))
1240 (oset obj first-pass-completions
1241 (semantic-analyze-possible-completions (oref obj context
))))
1242 ;; search our cached completion list. make it look like a semanticdb
1244 (list (cons (save-excursion
1245 (set-buffer (oref (oref obj context
) buffer
))
1246 semanticdb-current-table
)
1247 (semantic-find-tags-for-completion
1249 (oref obj first-pass-completions
)))))
1252 ;;; ------------------------------------------------------------
1253 ;;; Tag List Display Engines
1255 ;; A typical displayor accepts a pre-determined list of completions
1256 ;; generated by a collector. This format is in semanticdb search
1257 ;; form. This vaguely standard form is a bit challenging to navigate
1258 ;; because the tags do not contain buffer info, but the file assocated
1259 ;; with the tags preceed the tag in the list.
1261 ;; Basic displayors don't care, and can strip the results.
1262 ;; Advanced highlighting displayors need to know when they need
1263 ;; to load a file so that the tag in question can be highlighted.
1265 ;; Key interface methods to a displayor are:
1266 ;; * semantic-displayor-next-action
1267 ;; * semantic-displayor-set-completions
1268 ;; * semantic-displayor-current-focus
1269 ;; * semantic-displayor-show-request
1270 ;; * semantic-displayor-scroll-request
1271 ;; * semantic-displayor-focus-request
1273 (defclass semantic-displayor-abstract
()
1274 ((table :type
(or null semanticdb-find-result-with-nil
)
1276 :protection
:protected
1277 :documentation
"List of tags this displayor is showing.")
1278 (last-prefix :type string
1279 :protection
:protected
1280 :documentation
"Prefix associated with slot `table'")
1282 "Abstract displayor baseclass.
1283 Manages the display of some number of tags.
1284 Provides the basics for a displayor, including interacting with
1285 a collector, and tracking tables of completion to display."
1288 (defmethod semantic-displayor-cleanup ((obj semantic-displayor-abstract
))
1289 "Clean up any mess this displayor may have."
1292 (defmethod semantic-displayor-next-action ((obj semantic-displayor-abstract
))
1293 "The next action to take on the minibuffer related to display."
1294 (if (and (slot-boundp obj
'last-prefix
)
1295 (string= (oref obj last-prefix
) (semantic-completion-text))
1296 (eq last-command this-command
))
1300 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-abstract
)
1302 "Set the list of tags to be completed over to TABLE."
1303 (oset obj table table
)
1304 (oset obj last-prefix prefix
))
1306 (defmethod semantic-displayor-show-request ((obj semantic-displayor-abstract
))
1307 "A request to show the current tags table."
1310 (defmethod semantic-displayor-focus-request ((obj semantic-displayor-abstract
))
1311 "A request to for the displayor to focus on some tag option."
1314 (defmethod semantic-displayor-scroll-request ((obj semantic-displayor-abstract
))
1315 "A request to for the displayor to scroll the completion list (if needed)."
1316 (scroll-other-window))
1318 (defmethod semantic-displayor-focus-previous ((obj semantic-displayor-abstract
))
1319 "Set the current focus to the previous item."
1322 (defmethod semantic-displayor-focus-next ((obj semantic-displayor-abstract
))
1323 "Set the current focus to the next item."
1326 (defmethod semantic-displayor-current-focus ((obj semantic-displayor-abstract
))
1327 "Return a single tag currently in focus.
1328 This object type doesn't do focus, so will never have a focus object."
1331 ;; Traditional displayor
1332 (defcustom semantic-completion-displayor-format-tag-function
1333 #'semantic-format-tag-name
1334 "*A Tag format function to use when showing completions."
1336 :type semantic-format-tag-custom-list
)
1338 (defclass semantic-displayor-traditional
(semantic-displayor-abstract)
1340 "Display options in *Completions* buffer.
1341 Traditional display mechanism for a list of possible completions.
1342 Completions are showin in a new buffer and listed with the ability
1343 to click on the items to aid in completion.")
1345 (defmethod semantic-displayor-show-request ((obj semantic-displayor-traditional
))
1346 "A request to show the current tags table."
1348 ;; NOTE TO SELF. Find the character to type next, and emphesize it.
1350 (with-output-to-temp-buffer "*Completions*"
1351 (display-completion-list
1352 (mapcar semantic-completion-displayor-format-tag-function
1353 (semanticdb-strip-find-results (oref obj table
))))
1357 ;;; Abstract baseclass for any displayor which supports focus
1358 (defclass semantic-displayor-focus-abstract
(semantic-displayor-abstract)
1359 ((focus :type number
1360 :protection
:protected
1361 :documentation
"A tag index from `table' which has focus.
1362 Multiple calls to the display function can choose to focus on a
1363 given tag, by highlighting its location.")
1368 "Non-nil if focusing requires a tag's buffer be in memory.")
1370 "Abstract displayor supporting `focus'.
1371 A displayor which has the ability to focus in on one tag.
1372 Focusing is a way of differentiationg between multiple tags
1373 which have the same name."
1376 (defmethod semantic-displayor-next-action ((obj semantic-displayor-focus-abstract
))
1377 "The next action to take on the minibuffer related to display."
1378 (if (and (slot-boundp obj
'last-prefix
)
1379 (string= (oref obj last-prefix
) (semantic-completion-text))
1380 (eq last-command this-command
))
1382 (slot-boundp obj
'focus
)
1383 (slot-boundp obj
'table
)
1384 (<= (semanticdb-find-result-length (oref obj table
))
1385 (1+ (oref obj focus
))))
1386 ;; We are at the end of the focus road.
1388 ;; Focus on some item.
1392 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-focus-abstract
)
1394 "Set the list of tags to be completed over to TABLE."
1396 (slot-makeunbound obj
'focus
))
1398 (defmethod semantic-displayor-focus-previous ((obj semantic-displayor-focus-abstract
))
1399 "Set the current focus to the previous item.
1400 Not meaningful return value."
1401 (when (and (slot-boundp obj
'table
) (oref obj table
))
1402 (with-slots (table) obj
1403 (if (or (not (slot-boundp obj
'focus
))
1404 (<= (oref obj focus
) 0))
1405 (oset obj focus
(1- (semanticdb-find-result-length table
)))
1406 (oset obj focus
(1- (oref obj focus
)))
1410 (defmethod semantic-displayor-focus-next ((obj semantic-displayor-focus-abstract
))
1411 "Set the current focus to the next item.
1412 Not meaningful return value."
1413 (when (and (slot-boundp obj
'table
) (oref obj table
))
1414 (with-slots (table) obj
1415 (if (not (slot-boundp obj
'focus
))
1417 (oset obj focus
(1+ (oref obj focus
)))
1419 (if (<= (semanticdb-find-result-length table
) (oref obj focus
))
1423 (defmethod semantic-displayor-focus-tag ((obj semantic-displayor-focus-abstract
))
1424 "Return the next tag OBJ should focus on."
1425 (when (and (slot-boundp obj
'table
) (oref obj table
))
1426 (with-slots (table) obj
1427 (semanticdb-find-result-nth table
(oref obj focus
)))))
1429 (defmethod semantic-displayor-current-focus ((obj semantic-displayor-focus-abstract
))
1430 "Return the tag currently in focus, or call parent method."
1431 (if (and (slot-boundp obj
'focus
)
1432 (slot-boundp obj
'table
)
1433 ;; Only return the current focus IFF the minibuffer reflects
1434 ;; the list this focus was derived from.
1435 (slot-boundp obj
'last-prefix
)
1436 (string= (semantic-completion-text) (oref obj last-prefix
))
1439 (if (oref obj find-file-focus
)
1440 (semanticdb-find-result-nth-in-buffer (oref obj table
) (oref obj focus
))
1441 ;; result-nth returns a cons with car being the tag, and cdr the
1443 (car (semanticdb-find-result-nth (oref obj table
) (oref obj focus
))))
1445 (call-next-method)))
1447 ;;; Simple displayor which performs traditional display completion,
1448 ;; and also focuses with highlighting.
1449 (defclass semantic-displayor-traditional-with-focus-highlight
1450 (semantic-displayor-focus-abstract semantic-displayor-traditional
)
1451 ((find-file-focus :initform t
))
1452 "Display completions in *Completions* buffer, with focus highlight.
1453 A traditional displayor which can focus on a tag by showing it.
1454 Same as `semantic-displayor-traditional', but with selection between
1455 multiple tags with the same name done by 'focusing' on the source
1456 location of the different tags to differentiate them.")
1458 (defmethod semantic-displayor-focus-request
1459 ((obj semantic-displayor-traditional-with-focus-highlight
))
1460 "Focus in on possible tag completions.
1461 Focus is performed by cycling through the tags and highlighting
1462 one in the source buffer."
1463 (let* ((tablelength (semanticdb-find-result-length (oref obj table
)))
1464 (focus (semantic-displayor-focus-tag obj
))
1467 (rtable (cdr focus
))
1469 (nt (semanticdb-normalize-one-tag rtable rtag
))
1473 ;; If we fail to normalize, resete.
1474 (when (not tag
) (setq table rtable tag rtag
))
1476 (let ((buf (or (semantic-tag-buffer tag
)
1477 (and table
(semanticdb-get-buffer table
)))))
1478 ;; If no buffer is provided, then we can make up a summary buffer.
1481 (set-buffer (get-buffer-create "*Completion Focus*"))
1483 (insert "Focus on tag: \n")
1484 (insert (semantic-format-tag-summarize tag nil t
) "\n\n")
1486 (insert "From table: \n")
1487 (insert (object-name table
) "\n\n"))
1489 (insert "In buffer: \n\n")
1490 (insert (format "%S" buf
)))
1491 (setq buf
(current-buffer))))
1492 ;; Show the tag in the buffer.
1493 (if (get-buffer-window buf
)
1494 (select-window (get-buffer-window buf
))
1495 (switch-to-buffer-other-window buf t
)
1496 (select-window (get-buffer-window buf
)))
1497 ;; Now do some positioning
1499 (if (semantic-tag-with-position-p tag
)
1500 ;; Full tag positional information available
1502 (goto-char (semantic-tag-start tag
))
1503 ;; This avoids a dangerous problem if we just loaded a tag
1504 ;; from a file, but the original position was not updated
1505 ;; in the TAG variable we are currently using.
1506 (semantic-momentary-highlight-tag (semantic-current-tag))
1508 (select-window (minibuffer-window)))
1509 ;; Calculate text difference between contents and the focus item.
1510 (let* ((mbc (semantic-completion-text))
1511 (ftn (semantic-tag-name tag
))
1512 (diff (substring ftn
(length mbc
))))
1513 (semantic-completion-message
1514 (format "%s [%d of %d matches]" diff
(1+ (oref obj focus
)) tablelength
)))
1518 ;;; Tooltip completion lister
1520 ;; Written and contributed by Masatake YAMATO <jet@gyve.org>
1522 ;; Modified by Eric Ludlam for
1523 ;; * Safe compatibility for tooltip free systems.
1524 ;; * Don't use 'avoid package for tooltip positioning.
1526 (defclass semantic-displayor-tooltip
(semantic-displayor-traditional)
1527 ((max-tags :type integer
1532 "Max number of tags displayed on tooltip at once.
1533 If `force-show' is 1, this value is ignored with typing tab or space twice continuously.
1534 if `force-show' is 0, this value is always ignored.")
1535 (force-show :type integer
1536 :initarg
:force-show
1538 :custom
(choice (const
1539 :tag
"Show when double typing"
1545 :tag
"Show if the number of tags is less than `max-tags'."
1548 "Control the behavior of the number of tags is greater than `max-tags'.
1549 -1 means tags are never shown.
1550 0 means the tags are always shown.
1551 1 means tags are shown if space or tab is typed twice continuously.")
1552 (typing-count :type integer
1555 "Counter holding how many times the user types space or tab continuously before showing tags.")
1556 (shown :type boolean
1559 "Flag representing whether tags is shown once or not.")
1561 "Display completions options in a tooltip.
1562 Display mechanism using tooltip for a list of possible completions.")
1564 (defmethod initialize-instance :AFTER
((obj semantic-displayor-tooltip
) &rest args
)
1565 "Make sure we have tooltips required."
1571 (defmethod semantic-displayor-show-request ((obj semantic-displayor-tooltip
))
1572 "A request to show the current tags table."
1573 (if (or (not (featurep 'tooltip
)) (not tooltip-mode
))
1574 ;; If we cannot use tooltips, then go to the normal mode with
1575 ;; a traditional completion buffer.
1577 (let* ((tablelong (semanticdb-strip-find-results (oref obj table
)))
1578 (table (semantic-unique-tag-table-by-name tablelong
))
1579 (l (mapcar semantic-completion-displayor-format-tag-function table
))
1581 (typing-count (oref obj typing-count
))
1582 (force-show (oref obj force-show
))
1583 (matchtxt (semantic-completion-text))
1585 (if (or (oref obj shown
)
1586 (< ll
(oref obj max-tags
))
1587 (and (<= 0 force-show
)
1588 (< (1- force-show
) typing-count
)))
1590 (oset obj typing-count
0)
1593 ;; We Have only one possible match. There could be two cases.
1594 ;; 1) input text != single match.
1596 ;; 2) input text == single match.
1597 ;; --> Complain about it, but still show the match.
1598 (if (string= matchtxt
(semantic-tag-name (car table
)))
1599 (setq msg
(concat "[COMPLETE]\n" (car l
)))
1601 ;; Create the long message.
1602 (setq msg
(mapconcat 'identity l
"\n"))
1603 ;; If there is nothing, say so!
1604 (if (eq 0 (length msg
))
1605 (setq msg
"[NO MATCH]")))
1606 (semantic-displayor-tooltip-show msg
))
1607 ;; The typing count determines if the user REALLY REALLY
1608 ;; wanted to show that much stuff. Only increment
1609 ;; if the current command is a completion command.
1610 (if (and (stringp (this-command-keys))
1611 (string= (this-command-keys) "\C-i"))
1612 (oset obj typing-count
(1+ typing-count
)))
1613 ;; At this point, we know we have too many items.
1614 ;; Lets be brave, and truncate l
1615 (setcdr (nthcdr (oref obj max-tags
) l
) nil
)
1616 (setq msg
(mapconcat 'identity l
"\n"))
1619 (semantic-displayor-tooltip-show (concat msg
"\n...")))
1621 (semantic-displayor-tooltip-show (concat msg
"\n(TAB for more)")))
1627 (if (fboundp 'window-inside-edges
)
1629 (defalias 'semantic-displayor-window-edges
1630 'window-inside-edges
)
1632 (defalias 'semantic-displayor-window-edges
1636 (defun semantic-displayor-point-position ()
1637 "Return the location of POINT as positioned on the selected frame.
1638 Return a cons cell (X . Y)"
1639 (let* ((frame (selected-frame))
1640 (left (frame-parameter frame
'left
))
1641 (top (frame-parameter frame
'top
))
1642 (point-pix-pos (posn-x-y (posn-at-point)))
1643 (edges (window-inside-pixel-edges (selected-window))))
1644 (cons (+ (car point-pix-pos
) (car edges
) left
)
1645 (+ (cdr point-pix-pos
) (cadr edges
) top
))))
1648 (defun semantic-displayor-tooltip-show (text)
1649 "Display a tooltip with TEXT near cursor."
1650 (let ((point-pix-pos (semantic-displayor-point-position))
1651 (tooltip-frame-parameters
1652 (append tooltip-frame-parameters nil
)))
1654 (cons 'left
(+ (car point-pix-pos
) (frame-char-width)))
1655 tooltip-frame-parameters
)
1657 (cons 'top
(+ (cdr point-pix-pos
) (frame-char-height)))
1658 tooltip-frame-parameters
)
1659 (tooltip-show text
)))
1661 (defmethod semantic-displayor-scroll-request ((obj semantic-displayor-tooltip
))
1662 "A request to for the displayor to scroll the completion list (if needed)."
1663 ;; Do scrolling in the tooltip.
1664 (oset obj max-tags
30)
1665 (semantic-displayor-show-request obj
)
1668 ;; End code contributed by Masatake YAMATO <jet@gyve.org>
1671 ;;; Ghost Text displayor
1673 (defclass semantic-displayor-ghost
(semantic-displayor-focus-abstract)
1675 ((ghostoverlay :type overlay
1677 "The overlay the ghost text is displayed in.")
1678 (first-show :initform t
1680 "Non nil if we have not seen our first show request.")
1682 "Cycle completions inline with ghost text.
1683 Completion displayor using ghost chars after point for focus options.
1684 Whichever completion is currently in focus will be displayed as ghost
1685 text using overlay options.")
1687 (defmethod semantic-displayor-next-action ((obj semantic-displayor-ghost
))
1688 "The next action to take on the inline completion related to display."
1689 (let ((ans (call-next-method))
1690 (table (when (slot-boundp obj
'table
)
1692 (if (and (eq ans
'displayend
)
1694 (= (semanticdb-find-result-length table
) 1)
1699 (defmethod semantic-displayor-cleanup ((obj semantic-displayor-ghost
))
1700 "Clean up any mess this displayor may have."
1701 (when (slot-boundp obj
'ghostoverlay
)
1702 (semantic-overlay-delete (oref obj ghostoverlay
)))
1705 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-ghost
)
1707 "Set the list of tags to be completed over to TABLE."
1710 (semantic-displayor-cleanup obj
)
1714 (defmethod semantic-displayor-show-request ((obj semantic-displayor-ghost
))
1715 "A request to show the current tags table."
1716 ; (if (oref obj first-show)
1718 ; (oset obj first-show nil)
1719 (semantic-displayor-focus-next obj
)
1720 (semantic-displayor-focus-request obj
)
1722 ;; Only do the traditional thing if the first show request
1723 ;; has been seen. Use the first one to start doing the ghost
1725 ; (call-next-method)
1729 (defmethod semantic-displayor-focus-request
1730 ((obj semantic-displayor-ghost
))
1731 "Focus in on possible tag completions.
1732 Focus is performed by cycling through the tags and showing a possible
1733 completion text in ghost text."
1734 (let* ((tablelength (semanticdb-find-result-length (oref obj table
)))
1735 (focus (semantic-displayor-focus-tag obj
))
1739 (semantic-completion-message "No tags to focus on.")
1740 ;; Display the focus completion as ghost text after the current
1742 (when (or (not (slot-boundp obj
'ghostoverlay
))
1743 (not (semantic-overlay-live-p (oref obj ghostoverlay
))))
1744 (oset obj ghostoverlay
1745 (semantic-make-overlay (point) (1+ (point)) (current-buffer) t
)))
1747 (let* ((lp (semantic-completion-text))
1748 (os (substring (semantic-tag-name tag
) (length lp
)))
1749 (ol (oref obj ghostoverlay
))
1752 (put-text-property 0 (length os
) 'face
'region os
)
1754 (semantic-overlay-put
1755 ol
'display
(concat os
(buffer-substring (point) (1+ (point)))))
1757 ;; Calculate text difference between contents and the focus item.
1758 (let* ((mbc (semantic-completion-text))
1759 (ftn (concat (semantic-tag-name tag
)))
1761 (put-text-property (length mbc
) (length ftn
) 'face
1763 (semantic-completion-message
1764 (format "%s [%d of %d matches]" ftn
(1+ (oref obj focus
)) tablelength
)))
1768 ;;; ------------------------------------------------------------
1769 ;;; Specific queries
1771 (defvar semantic-complete-inline-custom-type
1775 (let* ((C (intern (car class
)))
1776 (doc (documentation-property C
'variable-documentation
))
1777 (doc1 (car (split-string doc
"\n")))
1782 (eieio-build-class-alist semantic-displayor-abstract t
))
1784 "Possible options for inlince completion displayors.
1785 Use this to enable custom editing.")
1787 (defcustom semantic-complete-inline-analyzer-displayor-class
1788 'semantic-displayor-traditional
1789 "*Class for displayor to use with inline completion."
1791 :type semantic-complete-inline-custom-type
1794 (defun semantic-complete-read-tag-buffer-deep (prompt &optional
1798 "Ask for a tag by name from the current buffer.
1799 Available tags are from the current buffer, at any level.
1800 Completion options are presented in a traditional way, with highlighting
1801 to resolve same-name collisions.
1802 PROMPT is a string to prompt with.
1803 DEFAULT-TAG is a semantic tag or string to use as the default value.
1804 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
1805 HISTORY is a symbol representing a variable to store the history in."
1806 (semantic-complete-read-tag-engine
1807 (semantic-collector-buffer-deep prompt
:buffer
(current-buffer))
1808 (semantic-displayor-traditional-with-focus-highlight "simple")
1809 ;;(semantic-displayor-tooltip "simple")
1816 (defun semantic-complete-read-tag-project (prompt &optional
1820 "Ask for a tag by name from the current project.
1821 Available tags are from the current project, at the top level.
1822 Completion options are presented in a traditional way, with highlighting
1823 to resolve same-name collisions.
1824 PROMPT is a string to prompt with.
1825 DEFAULT-TAG is a semantic tag or string to use as the default value.
1826 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
1827 HISTORY is a symbol representing a variable to store the history in."
1828 (semantic-complete-read-tag-engine
1829 (semantic-collector-project-brutish prompt
1830 :buffer
(current-buffer)
1831 :path
(current-buffer)
1833 (semantic-displayor-traditional-with-focus-highlight "simple")
1840 (defun semantic-complete-inline-tag-project ()
1841 "Complete a symbol name by name from within the current project.
1842 This is similar to `semantic-complete-read-tag-project', except
1843 that the completion interaction is in the buffer where the context
1844 was calculated from.
1845 Customize `semantic-complete-inline-analyzer-displayor-class'
1846 to control how completion options are displayed.
1847 See `semantic-complete-inline-tag-engine' for details on how
1849 (let* ((collector (semantic-collector-project-brutish
1851 :buffer
(current-buffer)
1852 :path
(current-buffer)))
1853 (sbounds (semantic-ctxt-current-symbol-and-bounds))
1854 (syms (car sbounds
))
1855 (start (car (nth 2 sbounds
)))
1856 (end (cdr (nth 2 sbounds
)))
1857 (rsym (reverse syms
))
1858 (thissym (nth 1 sbounds
))
1859 (nextsym (car-safe (cdr rsym
)))
1861 (when (and thissym
(or (not (string= thissym
""))
1863 ;; Do a quick calcuation of completions.
1864 (semantic-collector-calculate-completions
1865 collector thissym nil
)
1866 ;; Get the master list
1867 (setq complst
(semanticdb-strip-find-results
1868 (semantic-collector-all-completions collector thissym
)))
1870 (setq complst
(semantic-unique-tag-table-by-name complst
))
1871 (if (or (and (= (length complst
) 1)
1872 ;; Check to see if it is the same as what is there.
1873 ;; if so, we can offer to complete.
1874 (let ((compname (semantic-tag-name (car complst
))))
1875 (not (string= compname thissym
))))
1876 (> (length complst
) 1))
1877 ;; There are several options. Do the completion.
1878 (semantic-complete-inline-tag-engine
1880 (funcall semantic-complete-inline-analyzer-displayor-class
1882 ;;(semantic-displayor-tooltip "simple")
1887 (defun semantic-complete-read-tag-analyzer (prompt &optional
1890 "Ask for a tag by name based on the current context.
1891 The function `semantic-analyze-current-context' is used to
1892 calculate the context. `semantic-analyze-possible-completions' is used
1893 to generate the list of possible completions.
1894 PROMPT is the first part of the prompt. Additional prompt
1895 is added based on the contexts full prefix.
1896 CONTEXT is the semantic analyzer context to start with.
1897 HISTORY is a symbol representing a variable to stor the history in.
1898 usually a default-tag and initial-input are available for completion
1899 prompts. these are calculated from the CONTEXT variable passed in."
1900 (if (not context
) (setq context
(semantic-analyze-current-context (point))))
1901 (let* ((syms (semantic-ctxt-current-symbol (point)))
1902 (inp (car (reverse syms
))))
1903 (setq syms
(nreverse (cdr (nreverse syms
))))
1904 (semantic-complete-read-tag-engine
1905 (semantic-collector-analyze-completions
1907 :buffer
(oref context buffer
)
1909 (semantic-displayor-traditional-with-focus-highlight "simple")
1911 (set-buffer (oref context buffer
))
1912 (goto-char (cdr (oref context bounds
)))
1913 (concat prompt
(mapconcat 'identity syms
".")
1920 (defun semantic-complete-inline-analyzer (context)
1921 "Complete a symbol name by name based on the current context.
1922 This is similar to `semantic-complete-read-tag-analyze', except
1923 that the completion interaction is in the buffer where the context
1924 was calculated from.
1925 CONTEXT is the semantic analyzer context to start with.
1926 Customize `semantic-complete-inline-analyzer-displayor-class'
1927 to control how completion options are displayed.
1929 See `semantic-complete-inline-tag-engine' for details on how
1931 (if (not context
) (setq context
(semantic-analyze-current-context (point))))
1932 (if (not context
) (error "Nothing to complete on here"))
1933 (let* ((collector (semantic-collector-analyze-completions
1935 :buffer
(oref context buffer
)
1937 (syms (semantic-ctxt-current-symbol (point)))
1938 (rsym (reverse syms
))
1939 (thissym (car rsym
))
1940 (nextsym (car-safe (cdr rsym
)))
1942 (when (and thissym
(or (not (string= thissym
""))
1944 ;; Do a quick calcuation of completions.
1945 (semantic-collector-calculate-completions
1946 collector thissym nil
)
1947 ;; Get the master list
1948 (setq complst
(semanticdb-strip-find-results
1949 (semantic-collector-all-completions collector thissym
)))
1951 (setq complst
(semantic-unique-tag-table-by-name complst
))
1952 (if (or (and (= (length complst
) 1)
1953 ;; Check to see if it is the same as what is there.
1954 ;; if so, we can offer to complete.
1955 (let ((compname (semantic-tag-name (car complst
))))
1956 (not (string= compname thissym
))))
1957 (> (length complst
) 1))
1958 ;; There are several options. Do the completion.
1959 (semantic-complete-inline-tag-engine
1961 (funcall semantic-complete-inline-analyzer-displayor-class
1963 ;;(semantic-displayor-tooltip "simple")
1964 (oref context buffer
)
1965 (car (oref context bounds
))
1966 (cdr (oref context bounds
))
1970 (defcustom semantic-complete-inline-analyzer-idle-displayor-class
1971 'semantic-displayor-ghost
1972 "*Class for displayor to use with inline completion at idle time."
1974 :type semantic-complete-inline-custom-type
1977 (defun semantic-complete-inline-analyzer-idle (context)
1978 "Complete a symbol name by name based on the current context for idle time.
1979 CONTEXT is the semantic analyzer context to start with.
1980 This function is used from `semantic-idle-completions-mode'.
1982 This is the same as `semantic-complete-inline-analyzer', except that
1983 it uses `semantic-complete-inline-analyzer-idle-displayor-class'
1984 to control how completions are displayed.
1986 See `semantic-complete-inline-tag-engine' for details on how
1988 (let ((semantic-complete-inline-analyzer-displayor-class
1989 semantic-complete-inline-analyzer-idle-displayor-class
))
1990 (semantic-complete-inline-analyzer context
)
1994 ;;; ------------------------------------------------------------
1997 (defun semantic-complete-test ()
1998 "Test completion mechanisms."
2001 (semantic-format-tag-prototype
2002 (semantic-complete-read-tag-project "Symbol: ")
2005 (defun semantic-complete-jump-local ()
2006 "Jump to a semantic symbol."
2008 (let ((tag (semantic-complete-read-tag-buffer-deep "Symbol: ")))
2009 (when (semantic-tag-p tag
)
2011 (goto-char (semantic-tag-start tag
))
2012 (semantic-momentary-highlight-tag tag
)
2014 (semantic-tag-class tag
)
2015 (semantic-tag-name tag
)))))
2017 (defun semantic-complete-jump ()
2018 "Jump to a semantic symbol."
2020 (let* ((tag (semantic-complete-read-tag-project "Symbol: ")))
2021 (when (semantic-tag-p tag
)
2023 (semantic-go-to-tag tag
)
2024 (switch-to-buffer (current-buffer))
2025 (semantic-momentary-highlight-tag tag
)
2027 (semantic-tag-class tag
)
2028 (semantic-tag-name tag
)))))
2030 (defun semantic-complete-analyze-and-replace ()
2031 "Perform prompt completion to do in buffer completion.
2032 `semantic-analyze-possible-completions' is used to determine the
2034 The minibuffer is used to perform the completion.
2035 The result is inserted as a replacement of the text that was there."
2037 (let* ((c (semantic-analyze-current-context (point)))
2038 (tag (save-excursion (semantic-complete-read-tag-analyzer "" c
))))
2039 ;; Take tag, and replace context bound with its name.
2040 (goto-char (car (oref c bounds
)))
2041 (delete-region (point) (cdr (oref c bounds
)))
2042 (insert (semantic-tag-name tag
))
2043 (message "%S" (semantic-format-tag-summarize tag
))))
2045 (defun semantic-complete-analyze-inline ()
2046 "Perform prompt completion to do in buffer completion.
2047 `semantic-analyze-possible-completions' is used to determine the
2049 The function returns immediately, leaving the buffer in a mode that
2050 will perform the completion.
2051 Configure `semantic-complete-inline-analyzer-displayor-class' to change
2052 how completion options are displayed."
2054 ;; Only do this if we are not already completing something.
2055 (if (not (semantic-completion-inline-active-p))
2056 (semantic-complete-inline-analyzer
2057 (semantic-analyze-current-context (point))))
2058 ;; Report a message if things didn't startup.
2059 (if (and (interactive-p)
2060 (not (semantic-completion-inline-active-p)))
2061 (message "Inline completion not needed.")
2062 ;; Since this is most likely bound to something, and not used
2063 ;; at idle time, throw in a TAB for good measure.
2064 (semantic-complete-inline-TAB)
2067 (defun semantic-complete-analyze-inline-idle ()
2068 "Perform prompt completion to do in buffer completion.
2069 `semantic-analyze-possible-completions' is used to determine the
2071 The function returns immediately, leaving the buffer in a mode that
2072 will perform the completion.
2073 Configure `semantic-complete-inline-analyzer-idle-displayor-class'
2074 to change how completion options are displayed."
2076 ;; Only do this if we are not already completing something.
2077 (if (not (semantic-completion-inline-active-p))
2078 (semantic-complete-inline-analyzer-idle
2079 (semantic-analyze-current-context (point))))
2080 ;; Report a message if things didn't startup.
2081 (if (and (interactive-p)
2082 (not (semantic-completion-inline-active-p)))
2083 (message "Inline completion not needed."))
2086 (defun semantic-complete-self-insert (arg)
2087 "Like `self-insert-command', but does completion afterwards.
2088 ARG is passed to `self-insert-command'. If ARG is nil,
2089 use `semantic-complete-analyze-inline' to complete."
2091 ;; If we are already in a completion scenario, exit now, and then start over.
2092 (semantic-complete-inline-exit)
2095 (self-insert-command arg
)
2097 ;; Prepare for doing completion, but exit quickly if there is keyboard
2099 (when (and (not (semantic-exit-on-input 'csi
2100 (semantic-fetch-tags)
2101 (semantic-throw-on-input 'csi
)
2104 (not (semantic-exit-on-input 'csi
2105 (semantic-analyze-current-context)
2106 (semantic-throw-on-input 'csi
)
2109 (semantic-complete-analyze-inline)
2110 ;; Ignore errors. Seems likely that we'll get some once in a while.
2114 ;; @TODO - I can't find where this fcn is used. Delete?
2117 ;(defun semantic-complete-inline-project ()
2118 ; "Perform inline completion for any symbol in the current project.
2119 ;`semantic-analyze-possible-completions' is used to determine the
2121 ;The function returns immediately, leaving the buffer in a mode that
2122 ;will perform the completion."
2124 ; ;; Only do this if we are not already completing something.
2125 ; (if (not (semantic-completion-inline-active-p))
2126 ; (semantic-complete-inline-tag-project))
2127 ; ;; Report a message if things didn't startup.
2128 ; (if (and (interactive-p)
2129 ; (not (semantic-completion-inline-active-p)))
2130 ; (message "Inline completion not needed."))
2134 (provide 'semantic
/complete
)
2136 ;;; semantic/complete.el ends here