From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Feature request/RFC: proper highlighting of code embedded in comments Date: Sun, 16 Oct 2016 13:42:46 -0400 Message-ID: References: <930446db-6dad-72a0-d0cd-a0710e5c6ec3@mit.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1476639853 24786 195.159.176.226 (16 Oct 2016 17:44:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Oct 2016 17:44:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 16 19:44:09 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bvpTW-00040J-F3 for ged-emacs-devel@m.gmane.org; Sun, 16 Oct 2016 19:43:54 +0200 Original-Received: from localhost ([::1]:57263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvpTY-0002yH-Kv for ged-emacs-devel@m.gmane.org; Sun, 16 Oct 2016 13:43:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvpSz-0002xK-Bg for emacs-devel@gnu.org; Sun, 16 Oct 2016 13:43:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvpSu-00080X-Fg for emacs-devel@gnu.org; Sun, 16 Oct 2016 13:43:21 -0400 Original-Received: from [195.159.176.226] (port=55717 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bvpSu-0007yv-9w for emacs-devel@gnu.org; Sun, 16 Oct 2016 13:43:16 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1bvpSa-0005E4-4p for emacs-devel@gnu.org; Sun, 16 Oct 2016 19:42:56 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 17 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:9XjJdYObpCzMSQCwwEGQRiUPUlw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:208332 Archived-At: FWIW, in sm-c-mode.el (in elpa.git), CPP directives are treated as comments, and since they do contain code, I have to solve the same kind of problem. I (ab)use for that purpose a syntactic face function. The starting point is: (setq-local font-lock-syntactic-face-function #'sm-c-syntactic-face-function) Take a look at sm-c-syntactic-face-function and especially sm-c--cpp-fontify-syntactically to see how I try to re-use the existing font-lock functionality. It's a bit gross, tho. Stefan