2
votes

I am using the auto-completion elisp for emacs. I am currently using it by pressing M-TAB but I would like it to also auto-complete after 4 characters.

I use yasnippet as a source for auto-complete so if I set it to auto-complete after 4 characters it won't show completions like if, for, inc, main.

If I set it to start auto-completion immediately then it gets in the way of my typing.

If I set a key binding and tell it start auto-completion after 4 characters, it ignores the key-bindings, and doesn't start completion

(setq ac-auto-start 4)
(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)

I would like for it to complete when I press M-TAB or after 4 characters.

EDIT: I tried

(setq ac-auto-start 4)
(global-set-key (kbd "M-TAB") 'ac-start)

I also have

(global-auto-complete-mode t)

It still didn't work. when I hit M-TAB it displays "Nothing to complete" in the minibuffer.

1

1 Answers

1
votes

"ac-mode-map" is only defined when the auto-complete popup is visible, so your "define-key" above won't work. Maybe use "global-set-key" instead.

Also, I believe you need to bind it to "ac-start", not "auto-complete".

In summary, try the following:

(setq ac-auto-start 4)
(global-set-key (kbd "M-TAB") 'ac-start)