问题
I would like that every time I open a .cpp file, semantic tag-folding would become activated. I am using the latest version of cedet (loading cedet-devel-load.el). I have
(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)
I added a hook
(add-hook 'c-mode-common-hook 'setupcpp)
and in 'setupcpp I simply have
(defun setupcpp ()
(interactive)
(semantic-tag-folding-mode t))
Nothing related to cedet/semantic happens after this in my .emacs. In fact, I could make this the only content of my .emacs.
It doesn't work. When opening a .cpp file I get the message File mode specification error: (error "Buffer foo.cpp cannot be folded by semantic").
Weirdly enough, if, once the file is open, I do M-x semantic-tag-folding-mode, it works! I am just lost.
回答1:
I got exactly the same error, using Emacs 24.3 and the newest cedet bzr version.
My solution is the following: Whenever something is decorated, the folding-mode will be enabled, too.
(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.
Works for me.
来源:https://stackoverflow.com/questions/15307113/emacs-cedet-semantic-tag-folding