From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Raffaele Ricciardi Newsgroups: gmane.emacs.help Subject: Re: font-lock-keywords: matcher function not working Date: Sat, 29 Jun 2013 10:53:48 +0200 Message-ID: References: <8d3f8211-d708-4e79-aab4-6cc8141c6c92@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1372514545 25918 80.91.229.3 (29 Jun 2013 14:02:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Jun 2013 14:02:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 29 16:02:29 2013 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 1UsvjO-00053z-Ku for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Jun 2013 16:02:26 +0200 Original-Received: from localhost ([::1]:50926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsvjO-00026c-5i for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Jun 2013 10:02:26 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-X-Trace: individual.net ESI8ckGqi3p0OnEVe28CAQ9/BDUYWOj+BKo8YrK52rfmmw41a9 Cancel-Lock: sha1:G2de3oCfGn2SL9WIC0ecPj5Zmpw= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: Original-Xref: usenet.stanford.edu gnu.emacs.help:199576 X-Mailman-Approved-At: Sat, 29 Jun 2013 10:02:12 -0400 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:91850 Archived-At: 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.