While editing C or C++ files in emacs, I'd like to be able to go to the beginning of the containing block of code. I was expecting to find a c-beginning-of-block function, but alas, no such function exists (to my knowledge). For example, I might be editing the following ugly C code:

void myFunction()
{
if (something) { //<--- I want to jump to this brace!
// do lots of stuff
if (stuff) {
// stuff
}
// more stuff
// ...
// I want to put my cursor somewhere on this line <---
// (anywhere just outside the following if) and call c-beginning-of-block
// and jump to the brace marked above (skipping "sibling" statements)
if (pizza_is_good) {
// do something
// wait, where am I?
}
// way more stuff
// ...
if (i_love_pizza) {
// eat pizza
}
}
}

I would be very surprised if this isn't already part of emacs, I just can't find it anywhere...

and C-M-n (forward-list) jumps to the end of block
–
FrancoisJun 25 '12 at 16:13

To keep jumping within the block from beginning to end, this does not solve the purpose because when I try to move to end of block C-M-n takes me to end of ) of a function call.
–
dknightFeb 24 at 6:07