From: Joe Corneli <jcorneli@math.utexas.edu>
Subject: regexp/font-lock question
Date: Tue, 18 May 2004 22:04:08 -0500 [thread overview]
Message-ID: <E1BQHNI-0000pE-00@linux183.ma.utexas.edu> (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)
next reply other threads:[~2004-05-19 3:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-19 3:04 Joe Corneli [this message]
[not found] <mailman.6162.1084935902.1061.help-gnu-emacs@gnu.org>
2004-05-19 14:30 ` regexp/font-lock question Thien-Thi Nguyen
2004-05-19 14:37 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1BQHNI-0000pE-00@linux183.ma.utexas.edu \
--to=jcorneli@math.utexas.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).