12

since I can't get CEDET to work for automatic code-completion (aka intelli-sense in the MS-world), after trying several times (no, it's just not working!), I've decided to use auto-complete, which works "quite fine" for me.

Unfortunately, auto-complete has an annoying behaviour when it comes to quit the imenu with its suggestions.

  1. auto-complete starts imenu, no matter how many suggestions it has. So, if there's only one suggestion, the menu appears. 1.
  2. To exit the imenu, I have to use the LEFT or RIGHT keys in order to make the menu disappear. ESC-ESC-ESC does not have any effect.

Is there any way, to modify these two behaviors?

Here's an excerpt of my .emacs file showing the auto-complete relevant stuff:

(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
(setq ac-delay 0.5) ;; eclipse uses 500ms

Kind regards, mefiX

paprika
  • 2,424
  • 26
  • 46
mefiX
  • 1,702
  • 3
  • 24
  • 39

1 Answers1

5

'Stop autocompleting' can be set by adding the following to your .emacs:

(define-key ac-completing-map "\ESC/" 'ac-stop)

...or alternatively you can use C-g as the default Emacs StopSomething command :)

As for showing the completion in a menu when there's only one candidate, I'm not really sure what other behaviour you'd want?

David Miller
  • 2,189
  • 2
  • 15
  • 17
  • I presume when there is only one candidate, the desired behavior would be to just insert that candidate. Some autocomplete engines do this even with a selection of candidates; they will cycle through all available candidates with successive hotkey activation. – Cheeso Nov 07 '10 at 14:55
  • Thank you, David Miller. Unfortunately, the key-assignment doesn't work in my case and I don't know why. For example, I'm editing my .emacs-file, where ac works very well. So I type "(def" and imenu pops up with (1+) suggestions (including "(defun"). When I hit "ESC", nothing happens. I've evaluated the "define-key" previously, of course. What am I doing wrong? – mefiX Nov 08 '10 at 09:55
  • 3
    Okay, after some trying, I figured out that pressing AND holding escape is what "\ESC/" stands for, which was not what I wanted. After some research, I found out that `(define-key ac-completing-map "\e" 'ac-stop)` does the trick! – mefiX Nov 08 '10 at 10:27