From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: Multi-line font-lock parser Date: Tue, 11 Aug 2009 07:28:42 +0300 Organization: A noiseless patient Spider Message-ID: <87ocqn55z9.fsf@iki.fi> References: <87tz0fwk7h.fsf@iki.fi> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1249965689 2463 80.91.229.12 (11 Aug 2009 04:41:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2009 04:41:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 11 06:41:21 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 1MajAm-0003hF-GN for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2009 06:41:20 +0200 Original-Received: from localhost ([127.0.0.1]:50297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MajAl-0004of-60 for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2009 00:41:19 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!weretis.net!feeder2.news.weretis.net!feeder.eternal-september.org!eternal-september.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-X-Trace: news.eternal-september.org U2FsdGVkX19YfTrYaRoz7D1TLawSbGYQUipeOjMud1CBbRvLP+JnGyLX2bjxbvObyFrBG7c6HtSs+f2Jhlz4R6+eBKct+RcTbGQx0QZinWe4sfNS1PN/X5tdxo6F6N9DGONyyZa2Lyl0Utqr2ondPg== Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Tue, 11 Aug 2009 04:36:55 +0000 (UTC) X-Auth-Sender: U2FsdGVkX18hulYaBP+/NnN/EqGMwGcYSiR9BUSvo1ziD9EqoyAgEQ== Cancel-Lock: sha1:M3Zbkp1AlqwAy44YyEOHMDfrw98= sha1:Kc9C7e5PnjhmTDlVVslyV+N8U5I= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:171865 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:67040 Archived-At: On 2009-08-10 23:32 (+0200), Thierry Volpiatto wrote: > Hi, > Teemu Likonen writes: > >> I'd like to write font-lock code which highlights the first line that >> (1) is non-empty and (2) does not start with a "#" comment character. >> This requires some multi-line parsing so plain regular expressions won't >> suffice. >> >> I'm too stupid to understand how to implement this kind of parsing. I >> can write a code which finds such a line but I don't know how to >> integrate it to font-lock. I don't understand the (info "(elisp) Font >> Lock Multiline") manual either. So I'd _really_ appreciate if someone >> posted an example code here. >> > Did you try to use add-text-properties? > Something like: > > ,---- > | (defun test-prop () > | (interactive) > | (when (re-search-forward "^[a-z]+") > | (beginning-of-line) > | (add-text-properties (1- (point-at-bol)) (point-at-eol) '(font-lock-face font-lock-comment-face)))) > `---- > > should work. Thanks but I don't know where to start. Care to elaborate how to integrate that with font-lock? I mean, who is going to run this test-prop function?