help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multi-line font-lock parser


From: Teemu Likonen
Subject: Re: Multi-line font-lock parser
Date: Tue, 11 Aug 2009 07:28:42 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

On 2009-08-10 23:32 (+0200), Thierry Volpiatto wrote:
> Hi,
> Teemu Likonen <tlikonen@iki.fi> 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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]