加C语言环境,安装 auto-complete-c-headers 按照官网文档配置
(defun my:ac-c-headers-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers))
(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
(add-hook 'c-mode-hook 'my:ac-c-headers-init)
当第一次打开某个.c文件时要卡很长时间,
如果在加上 (require 'auto-complete-c-headers)
配置成为如下,则在启动emacs的时候要卡很长时间,漫长的等待以后打开某个.c文件就会秒开
(require 'auto-complete-c-headers)
(defun my:ac-c-headers-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers))
(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
(add-hook 'c-mode-hook 'my:ac-c-headers-init)
--------在本论坛里搜补全好像大家都提倡用company,company也可以代码补全?
我现在的理解是company对文本具有补全功能
auto-complete对代码具有补全功能。
auto-complete要配合auto-complete-c-headers头文件补全+gtags才方便于代码文件书写,跳转。
—为什么我已启动emacs AC就一直开着
company效率比较高,另外,company也可以使用 tags
wrllinwr:
company也可以代码补全?
可以,能补全什么也由后端决定,比如如果要补全 C Header 的话,就需要写一个对应的 Company 后端。
看了baitianyu兄弟说company也可以补全,就重新尝试company。因为子龙的视频在前几集就把company包含进来了,一直以为他对代码不起做用。
在melp中搜到company打开文档,company文档的最下方有几个链接,其中一个是配置c ide如下地址:
http://tuhdo.github.io/c-ide.html#orgheadline1
就跟着这个一点一点的配置,还没全配置好。现在使用的是helm+helm-tags +company
tags跳转目前测试倒是可行了,头文件补全也还凑合 (sys/type.h sys能补全输入完/后就不提示了)。
/usr/include 想输入这种路径的时候 backend不会自动切换到company-files
“/usr/include” 会自动切换到company-files
helm-gtags配置如下
(setq
helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t
helm-gtags-prefix-key “\C-cg”
helm-gtags-suggested-key-mapping t
)
(require 'helm-gtags)
;; Enable helm-gtags-mode
(add-hook 'dired-mode-hook 'helm-gtags-mode)
(add-hook 'eshell-mode-hook 'helm-gtags-mode)
(add-hook 'c-mode-hook 'helm-gtags-mode)
(add-hook 'c+±mode-hook 'helm-gtags-mode)
(add-hook 'asm-mode-hook 'helm-gtags-mode)
(define-key helm-gtags-mode-map (kbd “C-c g a”) 'helm-gtags-tags-in-this-function)
(define-key helm-gtags-mode-map (kbd “C-j”) 'helm-gtags-select)
(define-key helm-gtags-mode-map (kbd “M-.”) 'helm-gtags-dwim)
(define-key helm-gtags-mode-map (kbd “M-,”) 'helm-gtags-pop-stack)
(define-key helm-gtags-mode-map (kbd “C-c <”) 'helm-gtags-previous-history)
(define-key helm-gtags-mode-map (kbd “C-c >”) 'helm-gtags-next-history)
这段配置加上emacs启动的时候就特别慢,通过一点点注释配置发现可能是我电脑的global gtags安装的问题???
emacs --debug-init 每次大概要等待一分钟才能启动完。
2017-02-22 12:12:08.893 Emacs-x86_64-10_9[1732:32526] IMKClient Stall detected, please Report your user scenario attaching a spindump (or sysdiagnose) that captures the problem - (imkxpc_bundleIdentifierWithReply:) block performed very slowly (1.57 secs).
现在不卡了,原因不明。只是卸载过monokai主题,重新安装过emacs
后来在增加的配置的时候在终端安装过一些其他软件,有的安装成功,有的失败,启动的时候又卡了
这两次卡的提示是:[yas] just-time-jump load snippet success。
也许跟auto-yasnippet yasnippet有关。
打包.emacs.d目录在linux虚拟机中启动运行都很正常。
但是在Mac上启动仍然不行,发现linux中用的是gun emacs 24.4.1,Mac中安装的是gun emacs 24.5.1 dmg,所以在Mac上卸载,重新安装emacs 24.4.1 dmg(源码编译报错,所以采用dmg)。问题消失鸟~~~。