Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs auto-complete-mode at startup

I just install auto-complete-mode, however everytime I start emacs I have to M-x auto-complete-mode. Is there anyway to have it loaded automatically ?

My .emacs is as follows:

;; auto-complete (add-to-list 'load-path "~/.emacs.d/") (require 'auto-complete-config) (add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict") (ac-config-default) 

Thanks

like image 891
w00d Avatar asked Nov 11 '11 14:11

w00d


People also ask

How do I enable autocomplete in Emacs?

The key to triggering the auto-completion in emacs is the Tab key. You will get a list of suggestions from the compiler. To select something from the list of suggestions, we recommend you to use C-n and C-p, but the down and up arrow keys can be used as well.

Does Emacs have code completion?

Auto-Complete is an intelligent auto-completion extension for Emacs. It extends the standard Emacs completion interface and provides an environment that allows users to concentrate more on their own work. Its features are: a visual interface, reduce overhead of completion by using statistic method, extensibility.


2 Answers

I think you can do it in various ways. To enable it globally you should use

(global-auto-complete-mode t) 

But it uses auto-complete-mode-maybe, which turn AC on only those listed in ac-modes. You can add them manually just like this

(add-to-list 'ac-modes 'sql-mode) 

You can make your own list if you wish AC be active only for few modes

(setq ac-modes '(c++-mode sql-mode)) 

Or rewrite it to have AC everywhere.

(defun auto-complete-mode-maybe ()   "No maybe for you. Only AC!"   (auto-complete-mode 1)) 

edited:

Autocomplete in minibuffer is bad. I think this will be better.

(defun auto-complete-mode-maybe ()   "No maybe for you. Only AC!"   (unless (minibufferp (current-buffer))     (auto-complete-mode 1))) 
like image 147
desudesudesu Avatar answered Oct 02 '22 13:10

desudesudesu


I just needed this:

(require 'auto-complete) (global-auto-complete-mode t) 

added to my .emacs.d/init.el file.

I installed auto-complete with the package manager. I'm using Emacs 24.

like image 32
Frank Henard Avatar answered Oct 02 '22 15:10

Frank Henard