Reputation: 1757
Is there a way to get autocomplete to popup after typing a "." or "->"?
I thought the code for this was
(add-to-list 'ac-omni-completion-sources
(cons "\\." '(ac-source-semantic)))
(add-to-list 'ac-omni-completion-sources
(cons "->" '(ac-source-semantic)))
But it seems like this may have been deprecated.
The closest I've see is Alex Ott's response here using:
(defun my-c-mode-cedet-hook ()
(local-set-key "." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert))
(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
However, this always pops up another frame to display the suggestions from semantic. I would like to have everything use autocomplete's native popup if possible, in such a manner that when I attempt reference a member function of a class using "myClass->", the autocomplete would popup with suggestions. Any idea if this can be accomplished?
Upvotes: 2
Views: 892
Reputation: 1928
Sorry big oversight on my comment. I'm at a bit of a loss. In Emacs 24.3.1 with autocomplete 1.3.1 I actually see the behavior that you want with autocomplete and semantic modes enabled. Namely, I get an automatic popup when typing one of:
someObj.
someObj->
I added this as an answer so I could list some code. If it helps, my autocomplete setup looks like:
(add-to-list 'load-path "<ac-install-dir>")
(require 'auto-complete-config)`
(add-to-list 'ac-dictionary-directories "<ac-install-dir>/ac-dict")
(ac-config-default)
(defun ac-common-setup ()
(setq ac-sources (append ac-sources '(ac-source-gtags ac-source-semantic ac-source-semantic-raw))))
It seems that the variable ac-prefix-definitions
governs patterns which are prefixes to trigger completion. The value I see is:
((symbol . ac-prefix-symbol)
(file . ac-prefix-file)
(valid-file . ac-prefix-valid-file)
(c-dot . ac-prefix-c-dot)
(c-dot-ref . ac-prefix-c-dot-ref))
ac-prefix-c-dot
and ac-prefix-c-dot-ref
seem to be the patterns which match .
and ->
to do the completion.
Upvotes: 1