5

If I set

(ac-set-trigger-key "C-o")

in .emacs, C-o does trigger auto-completion but TAB still does too. It seems that C-o is added to the triggers, while I want it to substitute TAB, so that when I press TAB no auto-completion is performed.

With YASnippet you can do something like:

(define-key yas-minor-mode-map (kbd "TAB") nil)

So that the binding is removed, is there something similar for auto-complete?

Dan
  • 32,584
  • 6
  • 98
  • 168
d-cmst
  • 275
  • 1
  • 5

1 Answers1

4

auto-complete defines three keymaps that might be relevant here:

  • ac-mode-map: This map is active when auto-complete-mode is enabled. ac-set-trigger-key adds the binding for the trigger key to this map.

  • ac-completing-map: This map is active during completion. By default, TAB is bound to ac-expand in this map.

  • ac-menu-map: This map is active while the popup showing possible completions is displayed (in addition to ac-completing-map), but only if ac-use-menu-map is set to a non-nil value.

If you want to make sure TAB won't do anything that's even remotely related to completion, you should probably "unset" the bindings in all of these maps (using the same technique you demonstrate for yas-minor-mode-map in your question).


UPDATE:

Here is a minimal configuration that keeps TAB from doing completion:

(package-initialize)
(require 'auto-complete-config)
(ac-config-default)
(define-key ac-mode-map (kbd "TAB") nil)
(define-key ac-completing-map (kbd "TAB") nil)
(define-key ac-completing-map [tab] nil)

You can try it out by starting Emacs via emacs -Q, copying the code into the *scratch* buffer and running M-x eval-buffer RET.

itsjeyd
  • 14,586
  • 3
  • 58
  • 87
  • thanks for your reply, after adding: `(define-key ac-mode-map (kbd "TAB") nil) (define-key ac-completing-map (kbd "TAB") nil) (define-key ac-menu-map (kbd "TAB") nil)` to my .emacs file TAB still does trigger auto-completion. Am I doing something wrong? – d-cmst Nov 28 '14 at 21:53
  • @dcmst I added a minimal configuration that does what you want to my answer. – itsjeyd Nov 29 '14 at 11:45
  • fyi for who is wondering: ‘-Q’ ‘--quick’ Start emacs with minimum customizations. This is similar to using ‘-q’, ‘--no-site-file’, ‘--no-site-lisp’, and ‘--no-splash’ together. This also stops Emacs from processing X resources by setting inhibit-x-resources to t (see Resources). From: Emacs Manual: Initial Options – mmlac Feb 19 '16 at 20:51