From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: font-lock Date: Thu, 17 Sep 2009 02:57:27 +0200 Message-ID: <874or2mlqg.fsf@fh-trier.de> References: <3026515d-2b01-40a9-9f03-9cd7babc55e0@p9g2000vbl.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253149110 32645 80.91.229.12 (17 Sep 2009 00:58:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Sep 2009 00:58:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 17 02:58:23 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mo5KI-0004T6-5l for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Sep 2009 02:58:22 +0200 Original-Received: from localhost ([127.0.0.1]:54604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mo5KH-0005xB-HT for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Sep 2009 20:58:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mo5Jw-0005x2-TV for help-gnu-emacs@gnu.org; Wed, 16 Sep 2009 20:58:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mo5Jr-0005wq-HQ for help-gnu-emacs@gnu.org; Wed, 16 Sep 2009 20:57:59 -0400 Original-Received: from [199.232.76.173] (port=37386 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mo5Jr-0005wn-CQ for help-gnu-emacs@gnu.org; Wed, 16 Sep 2009 20:57:55 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:57126) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mo5Jq-0005aw-Oi for help-gnu-emacs@gnu.org; Wed, 16 Sep 2009 20:57:55 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1Mo5Jn-0004NA-GL for help-gnu-emacs@gnu.org; Thu, 17 Sep 2009 02:57:51 +0200 Original-Received: from dslb-088-068-221-112.pools.arcor-ip.net ([88.68.221.112]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Sep 2009 02:57:51 +0200 Original-Received: from politza by dslb-088-068-221-112.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Sep 2009 02:57:51 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-088-068-221-112.pools.arcor-ip.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:hQVpcZGonJTNQSSqNVMA/OkYFRQ= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68223 Archived-At: Florian Kaufmann writes: [...] > (defconst adoc-font-lock-keywords > (eval-when-compile > (list > (cons "##.*$" 'font-lock-comment-face) > (cons "\".*?\"" 'font-lock-string-face) > ))) > > Now in my test buffer > > "foo##bar" > ##foo"bar" > > The first line is not correctly fontified. I expect that the while > line has the string face, but "foo has no face, and ##bar" has comment > face. If I reverse the two (cons ...) lines, then the 2nd line in the > test buffer is ill formated: ##foo has no face, and "bar" has comment > face; I expect the whole 2nd line to be in comment face. > ,----[ (info "(elisp) Search-based Fontification") ] | Each element of `font-lock-keywords' specifies how to find certain | cases of text, and how to highlight those cases. Font Lock mode | processes the elements of `font-lock-keywords' one by one, and for each | element, it finds and handles all matches. Ordinarily, once part of | the text has been fontified already, this cannot be overridden by a | subsequent match in the same text; but you can specify different | behavior using the OVERRIDE element of a SUBEXP-HIGHLIGHTER. `---- > I think I can't make use of syntax tables, because actually my > comments/strings are more complex (and even that is a bit simplified > for this post): > Why not use both ? Syntax tables for, what I suppose are, multiline matches (since they are difficult to do `by hand') and keywords for the rest. > comments > ##.*$ > #\w+ > #\*.*?\*# > > strings > ".*?" > '\w+ > '\[.*?\] > `\W+ -ap