From: Joakim Hove <hove@ift.uib.no>
Subject: Re: Fontification with a specific function
Date: Fri, 15 Oct 2004 12:27:16 +0200 [thread overview]
Message-ID: <bjj7jpsp98b.fsf@termo1.fi.uib.no> (raw)
In-Reply-To: b065b78c.0410150200.7dac3f7@posting.google.com
joao17@mailinator.com (joao) writes:
> I don't see where this "match data" is defined. Can anyone point me to
> an example, in the emacs sources or in some package, of this usage of
> fontification ?
<Disclaimer: I have never done this myself>
The match data is some global emacs variable/stack of the last regexp
search results. Let us say you you wanted to fontify the word 'horse'
then function could be like this:
(defun find-horse (p-max)
;; OK the regexp is probably far to simple, but it finds
;; "horse". Maybe the optional fourth argument COUNT should be
;; set??
(if (re-search-forward " \\(horse\\) " p-max t)
t nil))
This function will return t or nil depending on wether the string
horse was found, and if it was found. The match (i.e. horse), and
other information about the match can be found from the functions
match-string, match-beginning , match-data etc, and I guess that is
what the internals of the font-lock code does. Hence, the match data
is automatically set by the (re-search-forward ) function, you don't
have to do that.
Good luck
Joakim
--
Joakim Hove
hove AT ift uib no
+47 (55 5)8 27 90
http://www.ift.uib.no/~hove/
next prev parent reply other threads:[~2004-10-15 10:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-15 10:00 Fontification with a specific function joao
2004-10-15 10:27 ` Joakim Hove [this message]
2004-10-15 12:42 ` Oliver Scholz
2004-10-16 20:27 ` joao
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bjj7jpsp98b.fsf@termo1.fi.uib.no \
--to=hove@ift.uib.no \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.