all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Martin Stjernholm <mast@lysator.liu.se>
Cc: bug-cc-mode@gnu.org, bug-gnu-emacs@gnu.org, rms@gnu.org
Subject: Re: [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows]
Date: Sat, 19 Feb 2005 01:03:32 +0100	[thread overview]
Message-ID: <5bvf8p4drf.fsf@lister.roxen.com> (raw)
In-Reply-To: <E1CsBPC-0004xn-8P@fencepost.gnu.org> (Richard Stallman's message of "Fri, 21 Jan 2005 21:53:42 -0500")

Richard Stallman <rms@gnu.org> wrote:

> Would you please fix this, if it is still broken in the current
> sources?
>
> From: Erik <sigra@home.se>
> Subject: C++-mode: Syntax highlighting: wrong color for function identifier
> 	depending on the kind of whitespace that follows
> To: bug-gnu-emacs@gnu.org
> Date: Fri Jan 21 18:44:19 2005 +0100
>
> In GNU Emacs 21.3.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)

If I'm not mistaken, that version contains CC Mode 5.28, which is
before CC Mode took over the font locking responsibility. Still, the
situation is the same in 5.30, so I'll address the problem anyway, but
my discussion will be in the context of 5.30 and not 5.28.

> In C++-mode, type:
> void function(int x);
>
> The string "function" is blue, which is correct. Now type:
> void function           (int x);
>
> The color is still correct. But type:
> void function
>                         (int x);
>
> The color is suddenly yellow. This is clearly a bug.

I assume yellow is the color you have for font-lock-variable-name-face.

As I understand this, you type in your examples sequentially. I.e. at
one time the buffer contains the single line

    void function

and then you add a newline and continue to type "(int x)". If so, the
bug, or rather misfeature, is in the font-lock package: By design, it
only refontifies the current line on the fly. When you're leaving the
first line, CC Mode is only acting on the information given by the
incomplete declaration "void function", which it prefers to recognize
as a variable declaration. It's first when you enter the "(" on the
second line that it can correct that analysis. But then font-lock no
longer requests refontification of the line containing the function
name.

Both the font-lock package and CC Mode could be improved in this
regard, but in general it's very tricky to know whether a change
affects the meaning of some code further back in the buffer. To be
really correct, the whole buffer down to the point should be
considered for refontification for every change in the buffer.
Needless to say that would get much too slow very quickly.

In the cvs version of Emacs, the font-lock package has a new variable
`font-lock-multiline'. It doesn't appear to make a difference in this
case.

> /.../ The color of function identifiers should always be the same,
> and not depend on what kind of whitespace follows it.

Indeed, and the font lock patterns installed by CC Mode do consider
all syntactic whitespace the same, regardless of amount of newlines,
comments and preprocessor directives in it. But it's necessary to
fontify the whole region at once to get that into play.


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click


       reply	other threads:[~2005-02-19  0:03 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1CsBPC-0004xn-8P@fencepost.gnu.org>
2005-02-19  0:03 ` Martin Stjernholm [this message]
     [not found] <E1D94Wo-0006AP-W2@fencepost.gnu.org>
2005-03-09 21:18 ` [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows] Alan Mackenzie
2005-03-09 22:35   ` Stefan Monnier
2005-03-10  8:00     ` Alan Mackenzie
2005-03-10 13:01       ` Stefan Monnier
2005-03-10 15:16         ` D. R. E. Moonfire
2005-03-10 17:01           ` Stefan Monnier
2005-03-10 20:09         ` Alan Mackenzie
2005-03-10 20:53           ` Stefan Monnier
2005-03-10 22:42             ` Alan Mackenzie
2005-03-11 20:28           ` Richard Stallman
2005-03-11  1:48       ` Richard Stallman
2005-03-11 19:43         ` Alan Mackenzie
2005-03-10 22:13     ` Martin Stjernholm
2005-03-10 22:59       ` Stefan Monnier
2005-03-11 20:27         ` Richard Stallman
2005-03-13 16:19         ` Martin Stjernholm
2005-03-14  1:07           ` Stefan Monnier
2005-03-19 22:23             ` Martin Stjernholm
2005-03-19 22:30               ` Stefan Monnier
2005-03-11  1:47     ` Richard Stallman
2005-03-11  4:47       ` Stefan Monnier
2005-03-12  0:56         ` Richard Stallman
2005-03-12  1:00           ` Stefan Monnier
2005-03-13 15:30             ` Richard Stallman
2005-03-11  1:46   ` Richard Stallman
2005-03-11  1:46   ` Richard Stallman
2006-02-12 13:06     ` Ralf Angeli
2006-02-12 16:20       ` Stefan Monnier
2006-02-12 22:58         ` Ralf Angeli
2006-02-13 22:10           ` Stefan Monnier
2006-02-14  7:53             ` martin rudalics
2006-02-14 19:00               ` Stefan Monnier
2006-02-14 20:13                 ` martin rudalics
2006-02-14 21:08                   ` Stefan Monnier
2006-02-15 10:17                     ` martin rudalics
2006-02-15 10:38                       ` Ralf Angeli
2006-02-15 14:20                         ` martin rudalics
2006-02-15 14:56                           ` Ralf Angeli
2006-02-15 16:40                             ` martin rudalics
2006-02-15 17:03                               ` Ralf Angeli
2006-02-16 11:10                               ` Alan Mackenzie
2006-02-16 11:54                                 ` Vivek Dasmohapatra
2006-02-16 15:21                                 ` Stefan Monnier
2006-02-16 23:28                                   ` David Kastrup
2006-02-17 14:19                                     ` Stefan Monnier
2006-02-16 17:21                                 ` martin rudalics
2006-02-15 20:44                     ` Alan Mackenzie
2006-02-16  0:40                       ` Stefan Monnier
2006-02-15 20:56                   ` Alan Mackenzie
2006-02-16  8:56                     ` martin rudalics
2006-02-15 20:13               ` Alan Mackenzie
2006-02-16  9:02                 ` martin rudalics
2006-02-14  8:18             ` Werner LEMBERG
2006-02-14  8:49             ` Ralf Angeli
2006-02-14 19:05               ` Stefan Monnier
2006-02-14 21:12                 ` Ralf Angeli
2006-02-15 13:35                   ` Stefan Monnier
2006-02-15 14:05                     ` Ralf Angeli
2006-02-15 14:21                       ` Ralf Angeli
2006-02-15 20:33             ` Alan Mackenzie
2006-02-15 21:13               ` Stefan Monnier
2006-02-15 21:59                 ` Alan Mackenzie
2006-02-16 14:59                 ` Kim F. Storm
2006-02-16 16:37                   ` Stefan Monnier
2006-02-15 19:07         ` Alan Mackenzie
2006-02-15 21:42           ` Ralf Angeli
2006-02-16 11:20             ` Alan Mackenzie
2006-02-16 11:54               ` Ralf Angeli
2006-02-16 15:12                 ` Alan Mackenzie
2006-02-17  7:56                   ` martin rudalics
2006-02-17 11:32                     ` Ralf Angeli
2006-02-17 13:22                       ` martin rudalics
2006-02-17 13:33                         ` Ralf Angeli
2006-02-16 16:32                 ` Stefan Monnier
2006-02-16  0:38           ` Stefan Monnier
2006-02-16  9:51             ` Alan Mackenzie
2006-02-16 16:27               ` Stefan Monnier
2006-02-17  7:48                 ` martin rudalics
2006-02-17 14:36                   ` Stefan Monnier
2006-02-16 18:46               ` martin rudalics
2006-02-16  9:09           ` martin rudalics
2006-02-13  4:40       ` Richard M. Stallman
2006-02-13  5:25         ` Stefan Monnier
2006-02-14  0:39           ` Richard M. Stallman
2006-03-14 19:23         ` Alan Mackenzie
2006-03-14 22:11           ` Stefan Monnier
2006-03-15  8:52             ` martin rudalics
2006-03-15  9:02             ` Ralf Angeli
2006-03-15 10:22               ` Stefan Monnier
2006-03-15 11:40             ` Alan Mackenzie
2006-03-15 16:16               ` Stefan Monnier
2006-03-15 20:20           ` Richard Stallman
2006-02-15 19:34       ` Alan Mackenzie
2006-02-16  9:07         ` Ralf Angeli
2006-02-16  9:07         ` martin rudalics

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

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

  git send-email \
    --in-reply-to=5bvf8p4drf.fsf@lister.roxen.com \
    --to=mast@lysator.liu.se \
    --cc=bug-cc-mode@gnu.org \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=rms@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.