Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ code folding with emacs/cedet

Tags:

c++

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?

like image 947
Thomas W. Avatar asked Apr 19 '12 07:04

Thomas W.


1 Answers

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)

like image 120
Alex Ott Avatar answered Sep 23 '22 11:09

Alex Ott