unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: scame <laszlomail@protonmail.com>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Could the current font-lock mechanism support font locking code in comments?
Date: Tue, 30 Mar 2021 10:06:05 -0400	[thread overview]
Message-ID: <jwv8s64rb68.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <-vuXfnLB83FOYoLI0Kery7gGaun-l6OFzywSWZ6LMyJTpDGk9ooLIKfJ4xSCkYwNTK9IHgDhtkdxPw7kXZkyaippVgp7CRR3aMz7dbos3og=@protonmail.com> (scame's message of "Tue, 30 Mar 2021 07:40:25 +0000")

> Could current font lock support this somehow or there
> is no way that the same buffer part can be fontified
> two times by such competing rules?

`sm-c-mode` does exactly what you describe, except it does it inside
things the user doesn't think are comments: it sets up the buffer's
syntax-table such that preprocessor directives are treated a special
kinds of comments, and then it tells font-lock to apply the usual rules
inside those "comments".

IOW, the problem is just one of recognizing those comments that contain
code rather than text, which requires some kind of markup.


        Stefan




  reply	other threads:[~2021-03-30 14:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  7:40 Could the current font-lock mechanism support font locking code in comments? scame
2021-03-30 14:06 ` Stefan Monnier [this message]
2021-03-30 15:44   ` scame
2021-03-30 16:18     ` Stefan Monnier
2021-03-30 18:09       ` [External] : " Drew Adams
2021-03-31  0:10         ` Arthur Miller
2021-03-31  1:12         ` Stefan Monnier
2021-03-31  4:36           ` Drew Adams
2021-03-31  4:38             ` Drew Adams

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=jwv8s64rb68.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=laszlomail@protonmail.com \
    /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).