[Top][All Lists]

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

Re: font-lock function matcher sample

From: Stefan Monnier
Subject: Re: font-lock function matcher sample
Date: Tue, 27 Jul 2004 18:36:44 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> What I have currently is working correctly.  First I find a word.  If word,
> limit and point are the same as the previous time the function was called,
> I return `nil'.

The fact that you need to compare with last search indicates that there's
something fishy with your code.

>        (while (and (re-search-forward beatnik-font-matcher-regexp limit t)
>                 (not (= (beatnik-last-word-score) score-match))))

Here you lose the information about whether the search succeeded or failed
which the source of your problems.  I.e. if the search fails immediately
(typically you've hit LIMIT) then (= (beatnik-last-word-score) score-match)
will be true and your code will screw up.

How about the code below instead:

(defun beatnik-=-matcher-p (limit score-match)
   "Tries to find a word whose scrable score matches score-match.
If such a word was found, t is returned."
   (let (found)
     (while (and (setq found (re-search-forward
                              beatnik-font-matcher-regexp limit t))
                 (/= (beatnik-last-word-score) score-match)))

> Stephan and Alan, many thanks for helping me out.  Maybe your comments
> should find their way to the doc-string or the info pages?

>From what I can see, your problems had nothing to do understanding how
font-lock works.  But if you have a concrete suggestion for how to change
the docstring, patches are welcome.


reply via email to

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