使用emacs / cedet折叠c ++代码

时间:2012-04-19 07:41:59

标签: c++ emacs cedet

我想使用cedet包中的语义代码折叠(emacs)。我安装了1.1版本并将以下行添加到.emacs:

(load-file "~/software/cedet-1.1/common/cedet.el")

(require 'semantic-tag-folding)
(defun c-folding-hook ()
  (global-semantic-tag-folding-mode 1)
  (local-set-key (kbd "C-c <left>") 'semantic-tag-folding-fold-block)
  (local-set-key (kbd "C-c <right>") 'semantic-tag-folding-show-block)
)
(add-hook 'c-mode-common-hook 'c-folding-hook)

好的,当我现在加载c ++ c ++文件时,使用键绑定或直接运行相应命令时没有任何反应。出了什么问题?我忘记了什么吗?

2 个答案:

答案 0 :(得分:5)

首先,您不需要在(global-semantic-tag-folding-mode 1)defun - 一次运行此命令会更好......

但我认为,主要问题是你没有启用任何语义功能(参见this section in my article) - 至少你需要在加载CEDET后调用(semantic-load-enable-minimum-features)

P.S。你的代码对我有用(我在设置中使用semantic-load-enable-excessive-code-helpers

答案 1 :(得分:0)

尝试在(load-file "~/software/cedet-1.1/common/cedet.el")行之后在您的emacs配置文件中添加以下行;

(semantic-load-enable-code-helpers) ; Enable prototype help and smart completion