bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#10664: 24.0.93; JIT font-lock infloops in a C file


From: Alan Mackenzie
Subject: bug#10664: 24.0.93; JIT font-lock infloops in a C file
Date: Fri, 10 Feb 2012 11:28:57 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Eli and Stefan.

On Wed, Feb 08, 2012 at 02:28:53PM -0500, Stefan Monnier wrote:
> >> > For one particular fontification in socket.c, the "safe position" is 500
> >> > bytes back from the starting point, so jit-lock is pushed back these 500
> >> > bytes, fontifies the next 500 bytes (`jit-lock-chunk-size'), then has its
> >> > new start position set back 500 bytes, rinse, spin, repeat.
> >> Why is "jit-lock pushed back"?
> > Build Emacs revision #106728.  emacs -Q, then create the following C++
> > buffer:

> > #########################################################################
> > 1 template <typename T>
> > 2
> > 3
> > 4 void myfunc(T* p) {}
> > #########################################################################

> > This is fontified correctly.  Type a space on L2.  This is OK for half a
> > second, then context fontification messes up L4.  The correct
> > fontification can only be restored by a change to L4.

> That explains why *font-lock* needs to be applied to "L1-L4", but now
> why *jit-lock* needs to be affected.

I was mistaken in my original diagnosis.  What is really happening is
that CC Mode is trying to go out of nested parens/brackets to find the
beginning of a declaration.

c-beginning-of-decl-1 (which _never_ goes back outside of
parens/brackets/braces) was given a limit (- (point) 500) which took it
to just after a (.  Then we went back out of the (.  Then did
c-beginning-of-decl-1 again, which moved _forward_ to the limit.  Repeat,
repeat, repeat ad infinitum.

The following patch should fix this.  Eli, would you please try it out
and let me know if there are still problems with it.


*** orig/cc-mode.el     2012-02-10 10:55:54.000000000 +0000
--- cc-mode.el  2012-02-10 11:27:56.000000000 +0000
***************
*** 1140,1146 ****
      (goto-char (c-point 'bol new-pos))
      (when lit-limits                  ; Comment or string.
        (goto-char (car lit-limits)))
!     (setq bod-lim (max (- (point) 500) (point-min)))
  
      (while
        ;; Go to a less nested declaration each time round this loop.
--- 1140,1146 ----
      (goto-char (c-point 'bol new-pos))
      (when lit-limits                  ; Comment or string.
        (goto-char (car lit-limits)))
!     (setq bod-lim (c-determine-limit 500))
  
      (while
        ;; Go to a less nested declaration each time round this loop.
***************
*** 1158,1168 ****
         ;; Try and go out a level to search again.
         (progn
           (c-backward-syntactic-ws bod-lim)
!          (or (memq (char-before) '(?\( ?\[))
!              (and (eq (char-before) ?\<)
!                   (eq (c-get-char-property
!                        (1- (point)) 'syntax-table)
!                       c-<-as-paren-syntax))))
         (not (bobp)))
        (backward-char))
      new-pos))                         ; back over (, [, <.
--- 1158,1169 ----
         ;; Try and go out a level to search again.
         (progn
           (c-backward-syntactic-ws bod-lim)
!          (and (> (point) bod-lim)
!               (or (memq (char-before) '(?\( ?\[))
!                   (and (eq (char-before) ?\<)
!                        (eq (c-get-char-property
!                             (1- (point)) 'syntax-table)
!                            c-<-as-paren-syntax)))))
         (not (bobp)))
        (backward-char))
      new-pos))                         ; back over (, [, <.



>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

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