[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: font-lock function matcher sample
From: |
Arjan Bos |
Subject: |
Re: font-lock function matcher sample |
Date: |
Tue, 27 Jul 2004 20:12:23 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7) Gecko/20040616 |
Stefan Monnier wrote:
Basically calling FUNCTION as in
(FUNCTION lim)
should behave similarly (as far as mach-data, point, and
return value go) to
(re-search-forward RE lim t)
Thanks, that matches my ideas.
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'.
Otherwise I calculate the scrabble score for it and if that matches the
asked for scrabble score (say 6) then I return `t'. In all other cases,
I return `nil'
like in:
(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."
(if (and (re-search-forward beatnik-font-matcher-regexp limit t)
(= (beatnik-last-word-score) score-match))
(progn
(setq beatnik-last-match (list (match-string-no-properties 1)
limit
score-match
(point)))
t)
;; else
(if (equal (list (match-string-no-properties 1)
limit
score-match
(point))
beatnik-last-match)
;; we already found it, return nil
nil
;; else
(while (and (re-search-forward beatnik-font-matcher-regexp limit t)
(not (= (beatnik-last-word-score) score-match))))
(if (= (beatnik-last-word-score) score-match)
(progn
(setq beatnik-last-match (list (match-string-no-properties 1)
limit
score-match
(point)))
t)
;; else
nil))))
Stephan and Alan, many thanks for helping me out. Maybe your comments
should find their way to the doc-string or the info pages?
Thanks!
Arjan
--
--
If you really want to contact me, then replace the "I see you" text by
its three letter accronym, ICU.
Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett