From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: font-locking regexps ? Date: Mon, 26 Sep 2005 15:33:25 -0600 Message-ID: References: <874q8763vn.fsf@madamex.madamex.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1127771050 1377 80.91.229.2 (26 Sep 2005 21:44:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 26 Sep 2005 21:44:10 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 26 23:44:08 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EK0jT-0002dc-RO for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Sep 2005 23:41:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EK0jT-0005J2-2q for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Sep 2005 17:41:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EK0ix-0005C9-Eg for help-gnu-emacs@gnu.org; Mon, 26 Sep 2005 17:41:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EK0it-0005AA-0g for help-gnu-emacs@gnu.org; Mon, 26 Sep 2005 17:41:19 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EK0is-00055A-BD for help-gnu-emacs@gnu.org; Mon, 26 Sep 2005 17:41:18 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EK0fD-0001Gm-9Z for help-gnu-emacs@gnu.org; Mon, 26 Sep 2005 17:37:31 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EK0ct-0000Tq-N3 for help-gnu-emacs@gnu.org; Mon, 26 Sep 2005 23:35:07 +0200 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 26 Sep 2005 23:35:07 +0200 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 26 Sep 2005 23:35:07 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 62 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: <874q8763vn.fsf@madamex.madamex.dk> 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:29731 Archived-At: Mads Jensen wrote: > I am trying to write some code for coloring some regexps, but cannot > really make it work. Since regexps seem to be working a little bit > differently (| = \\| in emacs lisp and so on), I'd like some help. I am > trying to get some items in a list colored: > > > (codes-inducks > (eval-when-compile > (list > '("[YZ]. [0-9]{2}-[0-9]{2}-[0-9]" > "I .{9}" > "F .{8}" > "[DH] [0-9-]{6}" > "D 20[0-9-]{6}" > "W .{10}"))))) > The syntax of regular expressions is explained in the Regexps node of the Emacs manual. The syntax of strings is explained in the Syntax for Strings node of the Emacs Lisp manual, but the Regexps node of the Emacs manual mentions the key aspect (that each backslash of the regexp needs to be doubled in the string): | Here is a complicated regexp, stored in `sentence-end' and used by | Emacs to recognize the end of a sentence together with any whitespace | that follows. We show its Lisp syntax to distinguish the spaces from | the tab characters. In Lisp syntax, the string constant begins and | ends with a double-quote. `\"' stands for a double-quote as part of | the regexp, `\\' for a backslash as part of the regexp, `\t' for a tab, | and `\n' for a newline. | | "[.?!][]\"')]*\\($\\| $\\|\t\\| \\)[ \t\n]*" So I suspect your code should be: (codes-inducks '("[YZ]. [0-9]\\{2\\}-[0-9]\\{2\\}-[0-9]" "I .\\{9\\}" "F .\\{8\\}" "[DH] [0-9-]\\{6\\}" "D 20[0-9-]\\{6\\}" "W .\\{10\\}")) > and I'm using these code for coloring it: > > > (setq inducks-keywords > (list (cons keywords-inducks 'inducks-keyword-face) > (cons codes-inducks 'inducks-code-face))) > > > But it's not working. > > Please just point me to a major mode, that uses this. Someone refered me > to sql.el in an earlier thread, which helped me get some of the > font-lock part to work in a mode, I'm working on. M-x grep font-lock lisp/progmodes/*.el -- Kevin Rodgers