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

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

Re: font-lock-keywords: matcher function not working


From: Raffaele Ricciardi
Subject: Re: font-lock-keywords: matcher function not working
Date: Sat, 29 Jun 2013 10:53:48 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

On 29/06/13 04:35, Stefan Monnier wrote:
Thank you again, Stefan.  However, I still don't understand.

Your function should search for the first occurrence of the thing you're
looking for, between here and ^end and only if there isn't any should it
return nil.

Instead, your current function only checks whether "here" is a spot that
matches the thing you're looking for.  Instead, when you find out that
"here" is not a match, don't return nil: try to look further instead.
This is typically done with a loop.

In your case, I wouldn't use a function anyway: I'd just use a regexp
like "^[^ \t]*(".

Thank you for your attention, Stefan.  Now I understand what the font lock
engine requires.

Following your suggestion, this snippet performs the desired highlighting:

(font-lock-add-keywords 'lisp-interaction-mode
                        '(
("^[[:blank:]]*\\((\\)" 1 'font-lock-warning-face)
                          ))

However, unless I restart `lisp-interaction-mode', no highlighting occurs,
neither it does if I just restart `font-lock-mode'. Why is it so? I was expecting
`font-lock-fontify-buffer' to apply the new rules.



reply via email to

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