From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nikolaj Schumacher Newsgroups: gmane.emacs.help Subject: Re: Problem when optimizing font-lock-keywords Date: Tue, 21 Oct 2008 23:26:10 +0200 Message-ID: References: <86864f7e-d948-4d9c-b554-589cb1f9b660@y21g2000hsf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1224624409 8047 80.91.229.12 (21 Oct 2008 21:26:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2008 21:26:49 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: =?utf-8?Q?Nordl=C3=B6w?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 21 23:27:50 2008 connect(): Connection refused 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 1KsOlQ-0007Eb-8G for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Oct 2008 23:27:40 +0200 Original-Received: from localhost ([127.0.0.1]:38779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsOkK-0002zW-9Z for geh-help-gnu-emacs@m.gmane.org; Tue, 21 Oct 2008 17:26:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KsOk1-0002zR-6M for help-gnu-emacs@gnu.org; Tue, 21 Oct 2008 17:26:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KsOk0-0002zE-JI for help-gnu-emacs@gnu.org; Tue, 21 Oct 2008 17:26:12 -0400 Original-Received: from [199.232.76.173] (port=43192 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsOk0-0002zB-DD for help-gnu-emacs@gnu.org; Tue, 21 Oct 2008 17:26:12 -0400 Original-Received: from dd18200.kasserver.com ([85.13.138.168]:55976) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KsOjz-00068n-Ud for help-gnu-emacs@gnu.org; Tue, 21 Oct 2008 17:26:12 -0400 Original-Received: from thursday (BAH6f85.bah.pppool.de [77.135.111.133]) by dd18200.kasserver.com (Postfix) with ESMTP id E8EE8180AD380; Tue, 21 Oct 2008 23:26:16 +0200 (CEST) In-Reply-To: <86864f7e-d948-4d9c-b554-589cb1f9b660@y21g2000hsf.googlegroups.com> (=?utf-8?Q?=22Nordl=C3=B6w=22's?= message of "Tue\, 21 Oct 2008 07\:06\:13 -0700 \(PDT\)") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:59007 Archived-At: Nordl=C3=B6w wrote: > I am trying to optimize my extra calls to font-lock-add-keywords() by > concatenating the MATCHERs like follows: > > (defun pnw-fancy/sh-mode-font-locking () > "Fancy Shell Script Syntax Highlighting." > (font-lock-add-keywords > nil > (list > (cons (concat "\\((\\|)\\)" "?" > "\\(\\[\\|]\\|{\\|}\\)" "?" > "\\(,\\|;\\)") > '((1 'font-lock-parens-face keep) > (2 'font-lock-braces-face keep) > (3 'font-lock-separator-face keep))) > ) > t)) > (add-hook 'sh-mode-hook 'pnw-fancy/sh-mode-font-locking t) > > I believe this idea is used in emacs-lisp-mode() but I can't make it > work --- I get the error: > Error during redisplay: (error No match 1 in highlight (1 (quote font- > lock-parens-face) keep)) [5 times] > > What have I missed? I think all groups must be matched successfully or accessing them will throw an error. That isn't the case if the ? operator wasn't successful. So instead of "\\( (\\|) \\)?" do: "\\( \\(:? (\\|) \\)? \\)" (spaces added for readability) regards, Nikolaj Schumacher