From: Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl>
Subject: Re: font-lock function matcher sample
Date: Tue, 27 Jul 2004 20:12:23 +0200 [thread overview]
Message-ID: <ce6660$ci4$1@reader10.wxs.nl> (raw)
In-Reply-To: <jwvu0vu7ae9.fsf-monnier+gnu.emacs.help@gnu.org>
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
next prev parent reply other threads:[~2004-07-27 18:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-17 21:08 font-lock function matcher sample Arjan Bos
2004-07-25 8:26 ` Alan Mackenzie
2004-07-25 19:55 ` Arjan Bos
2004-07-26 20:59 ` Stefan Monnier
2004-07-26 21:00 ` Stefan Monnier
2004-07-27 18:12 ` Arjan Bos [this message]
2004-07-27 18:36 ` Stefan Monnier
2004-08-03 18:09 ` Arjan Bos
2004-08-03 18:39 ` Stefan Monnier
2004-08-04 18:56 ` Arjan Bos
2004-08-04 19:48 ` Stefan Monnier
2004-08-04 20:00 ` Arjan Bos
2004-08-04 20:08 ` Stefan Monnier
2004-08-05 19:16 ` Arjan Bos
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='ce6660$ci4$1@reader10.wxs.nl' \
--to=arjan.bos@nospam.iseeyou.nl \
--cc=Arjan.Bos@ISeeYou.nl \
/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).