我希望每次打开.cpp文件时,语义标签折叠将被激活。我正在使用最新版本的cedet(加载cedet-dev -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/语义相关的事情发生。事实上,我可以把它作为我的。emacs的唯一内容。
它不工作。当打开一个。cpp文件时,我得到消息文件模式规范错误:(错误"Buffer foo.cpp不能被语义折叠")。
奇怪的是,如果,一旦文件打开,我做M-x语义标签折叠模式,它工作!
我使用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.