From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: scame Newsgroups: gmane.emacs.devel Subject: Re: Could the current font-lock mechanism support font locking code in comments? Date: Tue, 30 Mar 2021 15:44:55 +0000 Message-ID: References: <-vuXfnLB83FOYoLI0Kery7gGaun-l6OFzywSWZ6LMyJTpDGk9ooLIKfJ4xSCkYwNTK9IHgDhtkdxPw7kXZkyaippVgp7CRR3aMz7dbos3og=@protonmail.com> Reply-To: scame Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36732"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 30 17:48:03 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRGb4-0009PF-OJ for ged-emacs-devel@m.gmane-mx.org; Tue, 30 Mar 2021 17:48:02 +0200 Original-Received: from localhost ([::1]:33198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRGb3-00051c-Mu for ged-emacs-devel@m.gmane-mx.org; Tue, 30 Mar 2021 11:48:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRGYG-0003Ww-Ry for emacs-devel@gnu.org; Tue, 30 Mar 2021 11:45:09 -0400 Original-Received: from mail-40140.protonmail.ch ([185.70.40.140]:27840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRGYD-0004BK-TJ for emacs-devel@gnu.org; Tue, 30 Mar 2021 11:45:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1617119103; bh=BxVMyJFFt4qDkQy0AaB7MtTyF7BZAXUEr/NrQ6nJxKQ=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=e4n+zMbM13tF03BypE/sbMuhgfvvhFne8D/OhgHMtnb02BMqdbeh8+7JFiDuznD/n DAy5Z7TBhT75l56jA7VR3m9i7tG5Wx0UAMR1bfJA0B+1n457ewNLpx5JY65zUQ9SpK YlFQ3ApPPfZUgootNN9ysPbNZW0WoSCMAUNeNxSk= In-Reply-To: Received-SPF: pass client-ip=185.70.40.140; envelope-from=laszlomail@protonmail.com; helo=mail-40140.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267182 Archived-At: > > `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". Sounds good. Though in this case the usual rules don't apply in the sense that it should use the dimmed version of the same colors, so that commented code is still visually distinct from uncommented code. Taking this example: // void func () { } the comment starter // should have regular comment color and the code inside should be syntax highlighted with dimmed colors of the regular faces. Does this complicate things? > > IOW, the problem is just one of recognizing those comments that contain > code rather than text, which requires some kind of markup. > Yes, some kind of markup should be necessary to activate syntax coloring in those comments.