🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #87266

[19.27]: font-lock-fontify-region should NOT use comment-end

#87266
From: Kevin Broadey
Date: Fri, 07 Oct 1994 11:56
38 lines
1770 bytes
Start up emacs -q -no-site-file and then M-x load-library font-lock.
Make sure the default font has an italic form.

Put the following in a C-mode buffer:-

----------------------------------------------------------------------

/*
   hello.c:  The traditional first C program.
*/

#include <stdio.h>

int main (int argc, char *argv[])
{
  printf ("Hello world!\n");
}

----------------------------------------------------------------------

Position the cursor at the start of the second line and eval the
following expression:-

	(font-lock-fontify-region (point) (point-max))

The whole region gets fontified in the COMMENT face (italics).

This is because when font-lock-fontify-region gets called within a
comment it searches for (regexp-quote comment-end) to find the end of
the comment.  This is wrong, because in c-mode comment-end is " */"
i.e. it has a leading space.

I guess the way to fix this is to find the end of the comment by
moving back to the beginning and then doing (forward-comment 1) which
is how font-lock-fontify-region does it later on.

--
Kevin
Technical Details
Message-ID: <9410061008.AA12558@bartley>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!cis.ohio-state.edu!bartley.DEmon.co.UK!KevinB

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,e3029e4fcce0f700,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1994-10-07 21:29:22 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!cis.ohio-state.edu!bartley.DEmon.co.UK!KevinB
From: KevinB@bartley.DEmon.co.UK (Kevin Broadey)
Newsgroups: gnu.emacs.bug
Subject: [19.27]: font-lock-fontify-region should NOT use comment-end
Date: 7 Oct 1994 07:56:20 -0400
Organization: GNUs Not Usenet
Lines: 38
Sender: daemon@cis.ohio-state.edu
Approved: bug-gnu-emacs@prep.ai.mit.edu
Distribution: gnu
Message-ID: <9410061008.AA12558@bartley>