From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Re: Font-lock of comments using comment tokens, does it work? Date: Sun, 7 Jun 2015 13:34:49 +0200 Message-ID: <20150607113448.GB32656@tuxteam.de> References: <20150605065300.GA26971@tuxteam.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1433676928 19864 80.91.229.3 (7 Jun 2015 11:35:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Jun 2015 11:35:28 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, Stefan Monnier To: =?iso-8859-1?Q?Bj=F6rn?= Lindqvist Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 07 13:35:17 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z1YrD-0000sB-1a for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Jun 2015 13:35:15 +0200 Original-Received: from localhost ([::1]:53998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1YrC-0008P8-8y for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Jun 2015 07:35:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1Yr1-0008Nm-7X for help-gnu-emacs@gnu.org; Sun, 07 Jun 2015 07:35:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1Yqy-0003NT-1v for help-gnu-emacs@gnu.org; Sun, 07 Jun 2015 07:35:03 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:56105 helo=tomasium.tuxteam.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1Yqx-0003H9-RX for help-gnu-emacs@gnu.org; Sun, 07 Jun 2015 07:34:59 -0400 Original-Received: from tomas by tomasium.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1Z1Yqn-0000SI-5q; Sun, 07 Jun 2015 13:34:49 +0200 In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 5.199.139.25 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104808 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, Jun 07, 2015 at 05:58:45AM +0200, Björn Lindqvist wrote: > Ok so I finally almost figured it out. The key part was that you must > invert the logic so that instead of "unmarking" in > syntax-propertize-rules, you use a regexp that adds the comment > starter property "<" to the matched strings. Something is bugged with > the unmarking approach, it's like it stops looking when it found the > comment character. Anyway: > > (syntax-propertize-rules > ("\\(^\\| \\|\t\\)\\(FOO\\|BAR\\)\\($\\| \\|\t\\)" (2 "< "))) Got it. > Does almost exactly what I want. Amusingly enough the matching is > case-INsensitive so bAR, Bar, foo, etc matches the regexp. But it's a > small flaw which I can live with. This is most probably related to the (buffer local) variable case-fold-search, which controls whether the regexp search functions are case sensitive or not. By default, it's set to t (that's what you usually expect interactively). You could try to set this variable to nil and see whether it works better. Alas, there doesn't seem to be a way to control that in the simple syntax-propertize-rules -- possibly you'll have to go the way of defining a syntax-propertize-function, where you can set this variable dynamically for the relevant call. Ducking around, here's a little snippet which might help to get you started: HTH, regards - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlV0LFgACgkQBcgs9XrR2kaEvwCcCR5xyTagZ/ihFBj7iv9keKTl pVAAnjRjsvahbfSW4+1sJ0UEconY1lz2 =5Ywn -----END PGP SIGNATURE-----