unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* regexp/font-lock question
@ 2004-05-19  3:04 Joe Corneli
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Corneli @ 2004-05-19  3:04 UTC (permalink / raw)


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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: regexp/font-lock question
       [not found] <mailman.6162.1084935902.1061.help-gnu-emacs@gnu.org>
@ 2004-05-19 14:30 ` Thien-Thi Nguyen
  2004-05-19 14:37   ` Thien-Thi Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2004-05-19 14:30 UTC (permalink / raw)


Joe Corneli <jcorneli@math.utexas.edu> writes:

>         '("[^N][ ()]\\(O\\)" 1 font-lock-type-face))

> what matcher should I be using to get these
> additionaly strings to fontify properly?

you can remove the need for the ^N kludge entirely,
by fontifying the header/footer w/ a rule that takes
precendence over this one.

thi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: regexp/font-lock question
  2004-05-19 14:30 ` Thien-Thi Nguyen
@ 2004-05-19 14:37   ` Thien-Thi Nguyen
  0 siblings, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2004-05-19 14:37 UTC (permalink / raw)


Thien-Thi Nguyen <ttn@glug.org> writes:

> precendence over this one.

oops, that should be "precedence".

anyway, this is the stone-sand-water approach to font-locking.

thi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-19 14:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-19  3:04 regexp/font-lock question Joe Corneli
     [not found] <mailman.6162.1084935902.1061.help-gnu-emacs@gnu.org>
2004-05-19 14:30 ` Thien-Thi Nguyen
2004-05-19 14:37   ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).