daj
daj

Reputation: 7183

emacs - "go to beginning of the function" doesn't work if function is enclosed in a namespace (C++)

In emacs, I use C-M-a and C-M-e to go the beginning/end of functions in C++ code. However, this functionality no longer works if the function is enclosed in a namespace (it just jumps to the beginning or end of the namespace enclosure). Does anyone have a good solution for this?

Upvotes: 5

Views: 786

Answers (2)

jxh
jxh

Reputation: 70422

Getting Emacs 24.1 which fixes the issue is the best course. If you are stuck on an older version of Emacs, a common work around was to use a preprocessor macro.

#define NAMESPACE_BEGIN(X) namespace X {
#define NAMESPACE_END      }

NAMESPACE_BEGIN(tools)

class Foo {
    //...
};

NAMESPACE_END

Some practitioners of this had other reasons. I personally liked how it prevented the default Emacs settings from indenting namespace'd code.

Upvotes: 2

pmr
pmr

Reputation: 59811

This is a known bug. It has been fixed in Emacs 24.1 which has been released three days ago. Get it. Unfortunately that fix has never been back-ported and it is unlikely that this will happen anytime soon.

Upvotes: 8

Related Questions