Emacs auto-complete-mode at startup

丶灬走出姿态 提交于 2019-12-17 21:58:27

问题


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


回答1:


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)))



回答2:


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.



来源:https://stackoverflow.com/questions/8095715/emacs-auto-complete-mode-at-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!