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: font-lock-keywords: matcher function not working Date: Thu, 27 Jun 2013 14:39:17 +0200 Message-ID: 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 1372349155 30545 80.91.229.3 (27 Jun 2013 16:05:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Jun 2013 16:05:55 +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 Jun 27 18:05:54 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 1UsEhl-000142-27 for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jun 2013 18:05:53 +0200 Original-Received: from localhost ([::1]:45941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsEhk-0003Lb-JT for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jun 2013 12:05:52 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-X-Trace: individual.net 1Chp+hiUKVfCaYTqjVdLWAUsecE7kjBmsebAmH9TO2VLadSJp0 Cancel-Lock: sha1:YhyY1Emz+/OKNbBgxjFz6OS8nHE= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 Original-Xref: usenet.stanford.edu gnu.emacs.help:199504 X-Mailman-Approved-At: Thu, 27 Jun 2013 12:05:27 -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:91785 Archived-At: Hello everybody, I'm trying to highlight the first parenthesis of each line in Lisp code. After having read the documentation of `font-lock-keywords', I've written a matcher function which behaves as required (I've tested it with `eval-expression'). However, first parentheses are not highlighted. Here is my code, tested on GNU Emacs 24.3 ;; Tested in the *scratch* buffer after "emacs -Q". (require 'cl) (defun* rr-first-non-blank? (&optional (point (point))) "Return non-NIL if POINT is on the first non-blank character of the current line." (= point (save-excursion (back-to-indentation) (point)))) (defun rr-match-indented-paren (^end) "Matcher for `font-lock-keywords' that matches a parenthesis made redundant by indentation." (if (and (eql (char-after) ?\() (rr-first-non-blank?)) (re-search-forward "(" ^end) nil)) (font-lock-add-keywords 'lisp-interaction-mode '( (rr-match-indented-paren . 'font-lock-warning-face) )) (font-lock-fontify-buffer)