Emacs auto-complete-mode at startup

前端 未结 2 1681
情话喂你
情话喂你 2020-12-13 04:29

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 a

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 04:53

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

提交回复
热议问题