Emacs CEDET语义标签折叠

时间:2013-03-09 04:22:42

标签: emacs lisp elisp emacs24 cedet

我希望每次打开.cpp文件时,语义标记折叠都会被激活。我使用的是最新版本的cedet(加载cedet-devel-load.el)。我有

(semantic-mode 1)
(require 'semantic/ia)
(require 'semantic/bovine/gcc)
(load-file "path/to/semantic/tag/folding/semantic-tag-folding.el")
(require 'semantic-tag-folding)

我添加了一个钩子

(add-hook 'c-mode-common-hook 'setupcpp)

并在'setupcpp中我只是

(defun setupcpp ()
(interactive)
(semantic-tag-folding-mode t))

在我的.emacs中没有任何与cedet / semantic相关的内容。事实上,我可以将其作为我的.emacs的唯一内容。

它不起作用。打开.cpp文件时,我收到消息文件模式规范错误:(错误“缓冲区foo.cpp不能通过语义折叠”)。

奇怪的是,如果文件打开后,我会做M-x语义标签折叠模式,它就可以了!我迷失了。

1 个答案:

答案 0 :(得分:4)

我使用Emacs 24.3和最新的cedet bzr版本得到了完全相同的错误。

我的解决方案如下: 每当装饰某些东西时,也会启用折叠模式。

(load-library "~/emacs/cedet/cedet-bzr/trunk/cedet-devel-load")
(load-library "contrib/semantic-tag-folding.el")

(defun do-after-decorate () (semantic-tag-folding-mode t) )
(add-hook 'semantic-decoration-mode-hook 'do-after-decorate) 
;; ... 
(semantic-load-enable-excessive-code-helpers) ; also starts the decorate-mode when useful.

适合我。