emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Huge {...} blocks in C/C++ again


From: Alan Mackenzie
Subject: Re: Huge {...} blocks in C/C++ again
Date: Wed, 23 Oct 2013 21:00:09 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello again, Dmitry.

On Mon, Oct 14, 2013 at 08:57:53PM +0400, Dmitry Antipov wrote:
> An issue from:

> https://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00483.html

> is exactly reproduced on this header from LLVM project, most probably
> due to huge

> #ifdef __cplusplus      <===============================
> extern "C" {
> #endif

> /* a lot of things */

> #ifdef __cplusplus
> }  // extern "C"
> #endif

> block -  a lot of things between top-level { and } hangs everything,
> without a chance to quit with C-g.

This isn't quite the cause.  What is actually happening is that CC Mode
is repeatedly searching backwards from the first "#ifdef" line for almost
any punctuation character which isn't in "syntactic whitespace" (i.e. in
a comment or macro).  Those 845 #defines take a lot of searching over.

This is a tricky one to fix, since I don't quite understand why the
critical bit of code is there.  It was inserted into the source in 2006,
but isn't itself buggy.  It is `c-at-toplevel-p' which is buggy.

But in the meantime, the following temporary patch should get your C Mode
scrolling again:



*** cc-fonts.el 2013-10-20 14:21:58.000000000 +0000
--- cc-fonts.el.temp    2013-10-23 20:36:31.000000000 +0000
***************
*** 1116,1126 ****
             "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
  
        (setq next-pos (match-beginning 0)
!           id-face (if (and (eq (char-after next-pos) ?\()
!                            (let (c-last-identifier-range)
!                              (save-excursion
!                                (goto-char next-pos)
!                                (c-at-toplevel-p))))
                        'font-lock-function-name-face
                      'font-lock-variable-name-face)
            got-init (and (match-beginning 1)
--- 1116,1122 ----
             "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
  
        (setq next-pos (match-beginning 0)
!           id-face (if (eq (char-after next-pos) ?\()
                        'font-lock-function-name-face
                      'font-lock-variable-name-face)
            got-init (and (match-beginning 1)



Thanks for the bug report.

> Dmitry

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]