emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: Font Lock on-the-fly misfontification in C++]


From: Stefan Monnier
Subject: Re: address@hidden: Font Lock on-the-fly misfontification in C++]
Date: Mon, 24 Jul 2006 10:35:08 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> Put the following in a fubar.cpp:

> class Fubar :
> public Foo,   // Foo fontified as a type, at first
> public Bar    // Bar fontified as a type, at first
> {
> Foo bar(Snafu snafu,  // Types, function, variable fontified, at first
> Foo foo,
> Bar bar);
> Foo bar(Snafu *snafu, // Types, function, variable fontified, at first
> Foo foo,
> Bar bar);
> };

> Then emacs -Q fubar.cpp.  I see Foo, Bar and Snafu fontified as types
> even where declaring functions and variables.  The corresponding
> functions and variables are fontified correctly.  This is great!

> Then do the following.

> 1.  Append a space to the first (or second) commented line.  Bug:
> fontification of Foo (or Bar) is removed from that line.

> 2.  Append a space to the third commented line.  Bug: fontification of Foo
> and bar is removed from that line.

> 3.  Append a space to the fourth commented line.  Bug: fontification of Foo,
> bar, Snafu and snafu is removed from that line.

The patch below seems to fix number 2 and 3 for me.  Someone who understands
cc-fonts.el better than me and thus knows where the two "public XXX" lines
are handled could probably do a similar adjustment for them.


        Stefan


--- orig/lisp/progmodes/cc-fonts.el
+++ mod/lisp/progmodes/cc-fonts.el
@@ -1111,6 +1111,10 @@
                ;; False alarm.  Return t to go on to the next check.
                t
 
+              (let ((beg (max (1- match-pos) (point-min))))
+                (if (< beg (line-beginning-position))
+                    (put-text-property beg (point) 'font-lock-multiline t)))
+
              (if (eq decl-or-cast 'cast)
                  ;; Save the position after the previous cast so we can feed
                  ;; it to `c-forward-decl-or-cast-1' in the next round.  That




reply via email to

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