* Problem with braces in C
@ 2009-11-05 10:07 Burkhard Schultheis
2009-11-05 18:06 ` Scott Frazer
2009-11-05 18:47 ` despen
0 siblings, 2 replies; 6+ messages in thread
From: Burkhard Schultheis @ 2009-11-05 10:07 UTC (permalink / raw)
To: help-gnu-emacs
We have overtaken a C program package with a horrible huge C function in
it (about 3500 lines of code in a single function!). Now Emacs 21.3.1
shows unbalanced braces at the first 5 opening braces. But:
1.) The code compiles without problems
2.) We can jump with match-paren to the corresponding closing braces
3.) A double-click with the left mouse button jumps to the corresponding
braces, too.
4.) indent-region indents perfectly the whole function.
Is it a known bug?
Thank you in advance!
Regards
Burkhard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with braces in C
2009-11-05 10:07 Problem with braces in C Burkhard Schultheis
@ 2009-11-05 18:06 ` Scott Frazer
2009-11-06 11:53 ` Burkhard Schultheis
2009-11-05 18:47 ` despen
1 sibling, 1 reply; 6+ messages in thread
From: Scott Frazer @ 2009-11-05 18:06 UTC (permalink / raw)
To: help-gnu-emacs
Burkhard Schultheis wrote:
> We have overtaken a C program package with a horrible huge C function in
> it (about 3500 lines of code in a single function!). Now Emacs 21.3.1
> shows unbalanced braces at the first 5 opening braces. But:
>
> 1.) The code compiles without problems
> 2.) We can jump with match-paren to the corresponding closing braces
> 3.) A double-click with the left mouse button jumps to the corresponding
> braces, too.
> 4.) indent-region indents perfectly the whole function.
>
> Is it a known bug?
>
Try setting blink-matching-paren-distance to nil.
Scott
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with braces in C
2009-11-05 10:07 Problem with braces in C Burkhard Schultheis
2009-11-05 18:06 ` Scott Frazer
@ 2009-11-05 18:47 ` despen
2009-11-05 20:16 ` Burkhard Schultheis
1 sibling, 1 reply; 6+ messages in thread
From: despen @ 2009-11-05 18:47 UTC (permalink / raw)
To: help-gnu-emacs
Burkhard Schultheis <burkhard.schultheis@web.de> writes:
> We have overtaken a C program package with a horrible huge C function
> in it (about 3500 lines of code in a single function!). Now Emacs
> 21.3.1 shows unbalanced braces at the first 5 opening braces. But:
>
> 1.) The code compiles without problems
> 2.) We can jump with match-paren to the corresponding closing braces
> 3.) A double-click with the left mouse button jumps to the
> corresponding braces, too.
> 4.) indent-region indents perfectly the whole function.
>
> Is it a known bug?
Are there #if/#ifdef around some parts of the braces?
That's what usually gets me.
In C code, it's better to use "if" and let the
optimizer make the choices. It doesn't confuse Emacs
and it's more readable.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with braces in C
2009-11-05 18:47 ` despen
@ 2009-11-05 20:16 ` Burkhard Schultheis
2009-11-05 23:52 ` Colin S. Miller
0 siblings, 1 reply; 6+ messages in thread
From: Burkhard Schultheis @ 2009-11-05 20:16 UTC (permalink / raw)
To: help-gnu-emacs
Am 05.11.2009 19:47, schrieb despen@verizon.net:
>
> Are there #if/#ifdef around some parts of the braces?
No. ;-)
Regards
Burkhard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with braces in C
2009-11-05 20:16 ` Burkhard Schultheis
@ 2009-11-05 23:52 ` Colin S. Miller
0 siblings, 0 replies; 6+ messages in thread
From: Colin S. Miller @ 2009-11-05 23:52 UTC (permalink / raw)
To: help-gnu-emacs
Burkhard Schultheis wrote:
> Am 05.11.2009 19:47, schrieb despen@verizon.net:
>>
>> Are there #if/#ifdef around some parts of the braces?
>
> No. ;-)
>
> Regards
> Burkhard
Hmm.
The normal way of spooking paren-mode is to do something like this, as Scott suggested
#if DEBUG
void myFunc(int a, float b, const char *FILE, int LINE) {
#else
void myFunc(int a, float b) {
#endif
replacing with
#if DEBUG
void myFunc(int a, float b, const char *FILE, int LINE)
#else
void myFunc(int a, float b)
#endif
{
will fix it.
As paren mode looks at the file before it pre-processed, it needs the brackets to match literally.
Other things that can spook it include (nb. brackets include {} () [] - if the order doesn't match, then
paren-mode can get confused)
1) Brackets in C++ style // comments, if C mode doesn't define these as a comment.
2) Brackets in pre-processor expansions.
Try placing the cursor immediately after the last curly bracket, and pressing
C-M-p. This will jump the cursor to what emacs thinks is the matching bracket.
Likewise, pressing C-M-n on an opening bracket will make the cursor jump
to the corresponding closing bracket.
hide-show-mode might be useful to see how emacs is blocking the code,
but hide-show-mode might get to confused to be much help.
HTH,
Colin S. Miller
--
Replace the obvious in my email address with the first three letters of the hostname to reply.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with braces in C
2009-11-05 18:06 ` Scott Frazer
@ 2009-11-06 11:53 ` Burkhard Schultheis
0 siblings, 0 replies; 6+ messages in thread
From: Burkhard Schultheis @ 2009-11-06 11:53 UTC (permalink / raw)
To: help-gnu-emacs
Am 05.11.2009 19:06, schrieb Scott Frazer:
> Burkhard Schultheis wrote:
>> We have overtaken a C program package with a horrible huge C function
>> in it (about 3500 lines of code in a single function!). Now Emacs
>> 21.3.1 shows unbalanced braces at the first 5 opening braces. But:
>>
>> 1.) The code compiles without problems
>> 2.) We can jump with match-paren to the corresponding closing braces
>> 3.) A double-click with the left mouse button jumps to the
>> corresponding braces, too.
>> 4.) indent-region indents perfectly the whole function.
>>
>> Is it a known bug?
>>
>
> Try setting blink-matching-paren-distance to nil.
Thank you very much. Now it works as it should.
Regards
Burkhard
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-11-06 11:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-05 10:07 Problem with braces in C Burkhard Schultheis
2009-11-05 18:06 ` Scott Frazer
2009-11-06 11:53 ` Burkhard Schultheis
2009-11-05 18:47 ` despen
2009-11-05 20:16 ` Burkhard Schultheis
2009-11-05 23:52 ` Colin S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).