unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Marti Bolivar <marti.f.bolivar@gmail.com>
To: Alan Mackenzie <acm@muc.de>
Cc: 28098@debbugs.gnu.org
Subject: bug#28098: 26.0.50; bad C fontification
Date: Mon, 21 Aug 2017 12:32:30 -0700	[thread overview]
Message-ID: <CADkizXhJypXAEioC90JTLskuu7e-tF4g93p8r8=g=_MhjDh3hw@mail.gmail.com> (raw)
In-Reply-To: <20170816205722.954.qmail@mail.muc.de>


[-- Attachment #1.1: Type: text/plain, Size: 2416 bytes --]

Hi Alan,

Thanks for the patch.

On Wed, Aug 16, 2017 at 1:57 PM, Alan Mackenzie <acm@muc.de> wrote:

> Hello again, Marti.
>
> In article <mailman.13159.1502810889.21957.bug-gnu-emacs@gnu.org> you
> wrote:
> > [-- text/plain, encoding 7bit, charset: UTF-8, 98 lines --]
>
> > 1. From emacs -Q, open this file:
>
>
> > https://github.com/zephyrproject-rtos/zephyr/blob/
> 2de59023dc726e61244eb7cca17252294016c65a/subsys/net/lib/http/http_client.c
>
> > 2. Observe incorrect syntax highlighting at beginning of file.
> Screenshot:
>
> >    https://postimg.org/image/tzy8qgjjz/
>
> >    (Note that loading a C file with just the #ifdefs and initial
> >    comment which fail to highlight above doesn't reproduce the issue.)
>
> I think the following patch should fix the bug.  Would you please apply
> it, try it out, and either confirm to me that it fixes the bug, or tell
> me what's still wrong:
>
>
> diff -r 9533dc4cbda3 cc-mode.el
> --- a/cc-mode.el        Thu Jul 27 17:37:02 2017 +0000
> +++ b/cc-mode.el        Wed Aug 16 20:48:54 2017 +0000
> @@ -1529,10 +1529,13 @@
>      (c-backward-syntactic-ws)
>      (when (setq pos1 (c-on-identifier))
>        (goto-char pos1)
> -      (when (and (c-forward-declarator)
> -                (eq (c-forward-token-2) 0))
> -       (c-backward-syntactic-ws)
> -       (point)))))
> +      (let ((lim (save-excursion
> +                  (and (c-beginning-of-macro)
> +                       (progn (c-end-of-macro) (point))))))
> +       (when (and (c-forward-declarator lim)
> +                  (eq (c-forward-token-2 1 nil lim) 0))
> +         (c-backward-syntactic-ws)
> +         (point))))))
>
>  (defun c-change-expand-fl-region (beg end old-len)
>    ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock
>

I couldn't manage to get this to apply, but I made the changes manually;
git format-patch output for the relevant commit is attached. This did
indeed resolve the issue.


>
> Thanks for taking the trouble to report this bug.
>
>
Thanks for taking the time to investigate and fix it.

Marti


> > In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
> >  of 2017-08-10 built on plop
> > Repository revision: 81656add8117e8d1b7faab18b330d0706462b433
> > Windowing system distributor 'The X.Org Foundation', version
> 11.0.11903000
> > System Description: Ubuntu 17.04
>
> --
> Alan Mackenzie (Nuremberg, Germany).
>
>

[-- Attachment #1.2: Type: text/html, Size: 3896 bytes --]

[-- Attachment #2: 0001-Test-c-fontification-fix.patch --]
[-- Type: text/x-patch, Size: 1196 bytes --]

From 95a39b33959b98f4b314c1c441060682bf49aa44 Mon Sep 17 00:00:00 2001
From: Marti Bolivar <marti.f.bolivar@gmail.com>
Date: Mon, 21 Aug 2017 11:47:29 -0700
Subject: [PATCH] Test c fontification fix

From: Alan Mackenzie <acm@muc.de>
---
 lisp/progmodes/cc-mode.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 0bf89b9a36..f27ec8722c 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1549,10 +1549,13 @@ c-fl-decl-end
     (c-backward-syntactic-ws)
     (when (setq pos1 (c-on-identifier))
       (goto-char pos1)
-      (when (and (c-forward-declarator)
-		 (eq (c-forward-token-2) 0))
-	(c-backward-syntactic-ws)
-	(point)))))
+      (let ((lim (save-excursion
+                  (and (c-beginning-of-macro)
+                       (progn (c-end-of-macro) (point))))))
+       (when (and (c-forward-declarator lim)
+                  (eq (c-forward-token-2 1 nil lim) 0))
+         (c-backward-syntactic-ws)
+         (point))))))
 
 (defun c-change-expand-fl-region (_beg _end _old-len)
   ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock
-- 
2.11.0


  reply	other threads:[~2017-08-21 19:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-15 14:45 bug#28098: 26.0.50; bad C fontification Marti Bolivar
     [not found] ` <mailman.13159.1502810889.21957.bug-gnu-emacs@gnu.org>
2017-08-16 17:49   ` Alan Mackenzie
2017-08-16 20:57   ` Alan Mackenzie
2017-08-21 19:32     ` Marti Bolivar [this message]
2017-08-22 17:17       ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADkizXhJypXAEioC90JTLskuu7e-tF4g93p8r8=g=_MhjDh3hw@mail.gmail.com' \
    --to=marti.f.bolivar@gmail.com \
    --cc=28098@debbugs.gnu.org \
    --cc=acm@muc.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).