unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums
@ 2015-01-23 23:36 Dima Kogan
       [not found] ` <handler.19669.B.14220562124798.ack@debbugs.gnu.org>
  2015-02-01 17:40 ` bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums Alan Mackenzie
  0 siblings, 2 replies; 7+ messages in thread
From: Dima Kogan @ 2015-01-23 23:36 UTC (permalink / raw)
  To: 19669

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

Hi. I'm running a very recent build of emacs from git revision 253d44b
(2015/01/08). I'm loading a very simple C file that has some enums
defined (attached). The enum elements all should have been rendered with

 font-lock-variable-name-face

However at startup with

 emacs -Q -nw

only some of the elements get this face; many have just the default
face. Pressing M-x changes things: some elements actually lose the
correct face. In general, using emacs tends to change what is or isn't
rendered properly. I'm attaching screenshots of the state at startup and
after M-x.

This is 100% reproducible on my end.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: db.h --]
[-- Type: text/x-chdr, Size: 630 bytes --]

enum xxx_xxxxxxxxxx_x
    {XXX_XXXX_XXXX_XXXXX_XXXXX,
     XXX_XXXX_XXXX_XXXXX_XXXXX,
     XXX_XXXX_XXXXXX_XXXXXXXX_XXXXXXX,
     XXX_XXXX_XXXXXX_XXXXXXXX_XXXXXXX,
     XXX_XXXX_XXXX_XXXXXXXX,
     XXXXXX_XXXXXXX_XXXX_XXXXXXXX,
     XXXXX_XXXXXX_XXXX_XXXXXXXX,
     XXX_XXXXXXX,
     XXX_XXX_XXXXXXXX,
     XXX_XXX_XXX_XXXXXXXXX,
     XXXXXX_XXX_XXXXXXX,
     X_XXXXXXXXXX};

enum xxx_xxxx_xxxxxxxxxx_x
    {XXX_XXXXXX_XXXX_XXX,
     XXX_XXXXXX_XXXX_XX,
     XXX_XXXXXXXX_XXXX_XXX,
     XXX_XXXX_XXXXXXX,
     XXX_XX_XXXXX_XXXX_XXXXXXX,
     XXXXXX_XXXXXX_XXXX_XXXXXXXX,
     XXX_XXXX_XXXXXXX,

     // xxx
     XXXXXX_XXXXXXXX};

[-- Attachment #3: startup.png --]
[-- Type: image/png, Size: 2660 bytes --]

[-- Attachment #4: Meta-x.png --]
[-- Type: image/png, Size: 2330 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#19669: Acknowledgement (25.0.50; c-mode: incorrect fontification of simple enums)
       [not found] ` <handler.19669.B.14220562124798.ack@debbugs.gnu.org>
@ 2015-01-24  5:29   ` Dima Kogan
  2015-01-24 15:27     ` Alan Mackenzie
  0 siblings, 1 reply; 7+ messages in thread
From: Dima Kogan @ 2015-01-24  5:29 UTC (permalink / raw)
  To: 19669

I just did some very simple tests. Emacs 24.4 has this issue also, but
Emacs 23.4 does not (it works). Would a full bisection be useful?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#19669: Acknowledgement (25.0.50; c-mode: incorrect fontification of simple enums)
  2015-01-24  5:29   ` bug#19669: Acknowledgement (25.0.50; c-mode: incorrect fontification of simple enums) Dima Kogan
@ 2015-01-24 15:27     ` Alan Mackenzie
  2015-02-01 21:27       ` Alan Mackenzie
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2015-01-24 15:27 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 19669

Hello, Dima.

On Fri, Jan 23, 2015 at 09:29:45PM -0800, Dima Kogan wrote:
> I just did some very simple tests. Emacs 24.4 has this issue also, but
> Emacs 23.4 does not (it works). Would a full bisection be useful?

I've just done that.  The bug is first apparent at (bugzilla) revision
106729 from 2011-12-24, summary: "Introduce a mechanism to widen the
region used in context font locking.".

I'll be looking at this.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums
  2015-01-23 23:36 bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums Dima Kogan
       [not found] ` <handler.19669.B.14220562124798.ack@debbugs.gnu.org>
@ 2015-02-01 17:40 ` Alan Mackenzie
  2015-02-01 20:13   ` Dima Kogan
  1 sibling, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2015-02-01 17:40 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 19669

Hello, Dima.

On Fri, Jan 23, 2015 at 03:36:33PM -0800, Dima Kogan wrote:
> Hi. I'm running a very recent build of emacs from git revision 253d44b
> (2015/01/08). I'm loading a very simple C file that has some enums
> defined (attached). The enum elements all should have been rendered with

>  font-lock-variable-name-face

> However at startup with

>  emacs -Q -nw

> only some of the elements get this face; many have just the default
> face. Pressing M-x changes things: some elements actually lose the
> correct face. In general, using emacs tends to change what is or isn't
> rendered properly. I'm attaching screenshots of the state at startup and
> after M-x.

> This is 100% reproducible on my end.



> enum xxx_xxxxxxxxxx_x
>     {XXX_XXXX_XXXX_XXXXX_XXXXX,
>      XXX_XXXX_XXXX_XXXXX_XXXXX,
>      XXX_XXXX_XXXXXX_XXXXXXXX_XXXXXXX,
>      XXX_XXXX_XXXXXX_XXXXXXXX_XXXXXXX,
>      XXX_XXXX_XXXX_XXXXXXXX,
>      XXXXXX_XXXXXXX_XXXX_XXXXXXXX,
>      XXXXX_XXXXXX_XXXX_XXXXXXXX,
>      XXX_XXXXXXX,
>      XXX_XXX_XXXXXXXX,
>      XXX_XXX_XXX_XXXXXXXXX,
>      XXXXXX_XXX_XXXXXXX,
>      X_XXXXXXXXXX};

> enum xxx_xxxx_xxxxxxxxxx_x
>     {XXX_XXXXXX_XXXX_XXX,
>      XXX_XXXXXX_XXXX_XX,
>      XXX_XXXXXXXX_XXXX_XXX,
>      XXX_XXXX_XXXXXXX,
>      XXX_XX_XXXXX_XXXX_XXXXXXX,
>      XXXXXX_XXXXXX_XXXX_XXXXXXXX,
>      XXX_XXXX_XXXXXXX,

>      // xxx
>      XXXXXX_XXXXXXXX};

What is triggering this bug is the fact you have the first enum element,
"XXX_XXXX_XXXX_XXXXX_XXXXX", on the same line as the "{".

On redisplay, CC Mode calculates a syntactically critical point, here the
beginning of "XXX_XXXX_XXXX_XXXXX_XXXXX" and requests fontification
starting there.  Font lock, however, decides to start fontification,
instead, at the BEGINNING OF THE LINE, which here is outside the "{",
hence things go wrong.

The solution is to remove the function from
`font-lock-extend-region-functions' which does this.

Please try out the following patch, and confirm that is does indeed solve
the problem (or tell me what isn't yet fixed).

Thanks for such a high quality bug report!



diff -r 33a71629ac14 cc-mode.el
--- a/cc-mode.el	Sun Jan 11 22:37:23 2015 +0000
+++ b/cc-mode.el	Sun Feb 01 17:34:19 2015 +0000
@@ -1242,6 +1242,14 @@
 	  (font-lock-mark-block-function
 	   . c-mark-function)))
 
+  ;; Prevent `font-lock-default-fontify-region' extending the region it will
+  ;; fontify to whole lines by removing `font-lock-extend-region-whole-lines'
+  ;; (and, coincidentally, `font-lock-extend-region-multiline' (which we do
+  ;; not need)) from `font-lock-extend-region-functions'.  (Emacs only).  This
+  ;; fixes Emacs bug #19669.
+  (when (boundp 'font-lock-extend-region-functions)
+    (setq font-lock-extend-region-functions nil))
+
   (make-local-variable 'font-lock-fontify-region-function)
   (setq font-lock-fontify-region-function 'c-font-lock-fontify-region)
 

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums
  2015-02-01 17:40 ` bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums Alan Mackenzie
@ 2015-02-01 20:13   ` Dima Kogan
  2015-02-01 21:58     ` Alan Mackenzie
  0 siblings, 1 reply; 7+ messages in thread
From: Dima Kogan @ 2015-02-01 20:13 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 19669

Alan Mackenzie <acm@muc.de> writes:

> Please try out the following patch, and confirm that is does indeed solve
> the problem (or tell me what isn't yet fixed).

Hi. This works great!


> Thanks for such a high quality bug report!

Thank you very much for fixing this. I'll let you close this bug when
you commit this patch





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#19669: Acknowledgement (25.0.50; c-mode: incorrect fontification of simple enums)
  2015-01-24 15:27     ` Alan Mackenzie
@ 2015-02-01 21:27       ` Alan Mackenzie
  0 siblings, 0 replies; 7+ messages in thread
From: Alan Mackenzie @ 2015-02-01 21:27 UTC (permalink / raw)
  To: 19669-done; +Cc: Dima Kogan

Bug fixed (in emacs-24 branch).

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums
  2015-02-01 20:13   ` Dima Kogan
@ 2015-02-01 21:58     ` Alan Mackenzie
  0 siblings, 0 replies; 7+ messages in thread
From: Alan Mackenzie @ 2015-02-01 21:58 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 19669

Hello, Dima.

On Sun, Feb 01, 2015 at 12:13:51PM -0800, Dima Kogan wrote:
> Alan Mackenzie <acm@muc.de> writes:

> > Please try out the following patch, and confirm that is does indeed solve
> > the problem (or tell me what isn't yet fixed).

> Hi. This works great!

Excellent!

> > Thanks for such a high quality bug report!

> Thank you very much for fixing this. I'll let you close this bug when
> you commit this patch

Yes, Sir!

I've committed the patch to the emacs-24 branch.  It should find its way
into the trunk in the normal course of things (with thanks to the person
who actually does this work).

And I've closed the bug.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-02-01 21:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-23 23:36 bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums Dima Kogan
     [not found] ` <handler.19669.B.14220562124798.ack@debbugs.gnu.org>
2015-01-24  5:29   ` bug#19669: Acknowledgement (25.0.50; c-mode: incorrect fontification of simple enums) Dima Kogan
2015-01-24 15:27     ` Alan Mackenzie
2015-02-01 21:27       ` Alan Mackenzie
2015-02-01 17:40 ` bug#19669: 25.0.50; c-mode: incorrect fontification of simple enums Alan Mackenzie
2015-02-01 20:13   ` Dima Kogan
2015-02-01 21:58     ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).