My problem is that imenu or speedbar/semantic fails because of indentation. For this simple file, it is ok:
#include <iostream>
void bar() {
std::cout << "bar" << std::endl;
}
But if I want to put function bar in a namespace and indent its code:
with speedbar (having
(require 'semantic/sb)
in init.el), I don't have the file tags in the speedbar frame, and I got "File mode specification error: (void-function c-subword-mode)" in minibufferwith M-X imenu, I got "No items suitable for an index found in this buffer" in minibuffer
Exemple code that fails:
#include <iostream>
namespace foo {
void bar() {
std::cout << "bar" << std::endl;
}
}
It is not the namespace that makes it fail, but the identation. The following fails too:
#include <iostream>
void bar() {
std::cout << "bar" << std::endl;
}
Any idea why and how to have it to work?
Thanks!!
EDIT: Ok the solution is indeed speedbar+sementics. It actually works (I had something wrong in my init.el...)
Maybe, the example regexp from
imenu.el
is used together withimenu-example--create-c-index
:The caret
^
at the beginning means beginning of line. If you insert[[:blank:]]*
behind it also function definitions with leading spaces are indexed.I do not know whether stuff like
gives false positives in this case. (You have to try.)
Actually, if I had sufficient time I would try to use
semantic
orctags
for the indexing. That would be much more robust.Note, I did not try this. I just had a look at
imenu.el
. (Currently, I do not have much spare time. Sorry.)