From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Joe Corneli Newsgroups: gmane.emacs.help Subject: regexp/font-lock question Date: Tue, 18 May 2004 22:04:08 -0500 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1084936011 24085 80.91.224.253 (19 May 2004 03:06:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 May 2004 03:06:51 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 19 05:06:44 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BQHPo-0006jx-00 for ; Wed, 19 May 2004 05:06:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BQHOf-00041p-B0 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 May 2004 23:05:33 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BQHNw-0003rE-Cu for help-gnu-emacs@gnu.org; Tue, 18 May 2004 23:04:48 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BQHNK-0002tD-Kt for help-gnu-emacs@gnu.org; Tue, 18 May 2004 23:04:42 -0400 Original-Received: from [146.6.139.124] (helo=dell3.ma.utexas.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BQHNI-0002qm-VR for help-gnu-emacs@gnu.org; Tue, 18 May 2004 23:04:09 -0400 Original-Received: from linux183.ma.utexas.edu (mail@linux183.ma.utexas.edu [146.6.139.172]) by dell3.ma.utexas.edu (8.11.0.Beta3/8.10.2) with ESMTP id i4J348q26350; Tue, 18 May 2004 22:04:08 -0500 Original-Received: from jcorneli by linux183.ma.utexas.edu with local (Exim 3.36 #1 (Debian)) id 1BQHNI-0000pE-00; Tue, 18 May 2004 22:04:08 -0500 Original-To: help-gnu-emacs X-all-your-base-are-belong-to-us: You are on the way to destruction. X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.4 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 Xref: main.gmane.org gmane.emacs.help:18584 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:18584 I'm running into something reminiscent of a problem I was having a while ago, which Jesper Harder put down to replace-match leaving the point after the replacement text (see below). But this time the problem comes up in font lock, not text replacement. Specifically, I thout it would be nice to fontify gnugo-board-mode, so I defined the following set of font-lock keywords: (defconst gnugo-font-lock-keywords (list '("X" . font-lock-builtin-face) '("[^N][ ()]\\(O\\)" 1 font-lock-type-face)) "Highlighting expressions for todl mode.") The [^N] in the second pattern is present to escape the O in "N O" that appears at the top and the bottom of the board. Things are working just fine until a pattern like "O O", "(O) O", or "O (O)" appears on the board, in which case the second O is not fontified properly. So my question is: what matcher should I be using to get these additionaly strings to fontify properly? multiple alternatives regexp question, Joe Corneli, 2004/01/06 > Unfortunately, when I search and replace like so: > > (let ((case-fold-search nil)) > (while (re-search-forward "\\([[:lower:]]\\|[[:digit:]]\\|A\\)\\([A-Z]\\)" > nil t) > (replace-match (concat (match-string 1) " " (match-string 2))))) > > on something like > > ProofOfPropertiesOfTraceOfAMatrix > > I get back > > Proof Of Properties Of Trace Of AMatrix > ^ > Why is the `A' not being treated the way I want the first time > around? Re: multiple alternatives regexp question, Jesper Harder, 2004/01/06 > It doesn't work because `replace-match' leaves point after the > replacement text. You could use something like this instead: > > (replace-match "\\1 " t nil nil 1)