[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fontification with a specific function

From: Joakim Hove
Subject: Re: Fontification with a specific function
Date: Fri, 15 Oct 2004 12:27:16 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.2 (gnu/linux)

address@hidden (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 Hove
hove AT ift uib no
+47 (55 5)8 27 90

reply via email to

[Prev in Thread] Current Thread [Next in Thread]