Search code examples
c++emacscedet

c++ code folding with emacs/cedet


I would like to use the semantic code folding from the cedet package (emacs). I installed the 1.1 version and added the following lines to .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)

Okay, when I now load a c oder c++ file, nothing happens when using the key bindings or directly running the corresponding commands. What's going wrong? Have I forgotten something?


Solution

  • First, you don't need to have (global-semantic-tag-folding-mode 1) inside defun - it's better to run this command once...

    But I think, that main problem is that you hadn't enabled any Semantic feature (see this section in my article) - at least you need to call (semantic-load-enable-minimum-features) after loading of CEDET.

    P.S. you code is working for me (I use semantic-load-enable-excessive-code-helpers in my setup)