启动时 Emacs 自动完成模式 [英] Emacs auto-complete-mode at startup

查看:30
本文介绍了启动时 Emacs 自动完成模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只安装了自动完成模式,但是每次启动 emacs 时我都必须 M-x 自动完成模式.有没有办法让它自动加载?

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 ?

我的.emacs如下:

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)

谢谢

推荐答案

我认为您可以通过多种方式实现.要全局启用它,您应该使用

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

(global-auto-complete-mode t)

但它使用 auto-complete-mode-maybe,它只打开 ac-modes 中列出的那些.您可以像这样手动添加它们

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)

如果您希望 AC 仅在少数模式下处于活动状态,您可以创建自己的列表

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

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

或者重写它,让 AC 无处不在.

Or rewrite it to have AC everywhere.

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

小缓冲区中的自动完成很糟糕.我认为这样会更好.

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

这篇关于启动时 Emacs 自动完成模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆