From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: regular expression help (again) Date: Thu, 24 Jan 2013 04:01:34 -0500 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1359018385 31120 80.91.229.3 (24 Jan 2013 09:06:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Jan 2013 09:06: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 Thu Jan 24 10:06:44 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 1TyIlc-0008O5-2E for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Jan 2013 10:06:40 +0100 Original-Received: from localhost ([::1]:38403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyIlK-0008A2-DZ for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Jan 2013 04:06:22 -0500 Original-Path: usenet.stanford.edu!news.kjsl.com!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 42 Injection-Info: barmar.motzarella.org; posting-host="78fb7125a45724f15e21604c94a7d968"; logging-data="19437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18NRahdgNMDb4hyMa6FJncU" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:iZHklJHzpEYdKOZPXUoNrKPLbyg= Original-Xref: usenet.stanford.edu gnu.emacs.help:196495 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:88789 Archived-At: In article , Luca Ferrari wrote: > Hi, > there is something I'm missing: I'm still writing my mode for a > programming language and I'd like to set a font-lock for a block of > lines that begins with /SOMETHING and ends with /* like the following: > > /MASK > Field 1: _____ > Field 2: _____ > /* > > So I defined the following regular expression to first match the whole block: > > "^/\w+[ \t\n]+(.*\n)/\*$" > > but it is not working, in particular testing it against > re-search-forward the \w+ works as expected but the [ \t\n]+ > subsedquent part is blocking the regular expression. What am I doing > wrong? > > Second question, within the same block would it be possible to set a > fot-lock for any word that is not made by underscores and to set > another font-lock for any _ found in the block? I need a little > suggestion about this (if possible). In Lisp code you need to double the backslashes that are used for regexp escape sequences, since backslash is also the string escape character. So change it to: "^/\\w+[ \t\n]+(.*\n)/\\*$" When you're typing a regexp interatively in response to a command prompt, you don't need to do this. However, \t and \n don't have any special meaning in regexp syntax (they're part of string syntax), so you have to enter them literally with C-q TAB anc C-q C-j. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***