From: Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl>
Subject: Re: font-lock function matcher sample
Date: Sun, 25 Jul 2004 21:55:09 +0200 [thread overview]
Message-ID: <ce13el$l9g$1@reader10.wxs.nl> (raw)
In-Reply-To: <lrqvdc.i9.ln@acm.acm>
Alan Mackenzie wrote:
> Arjan Bos <Arjan.Bos@nospam.iseeyou.nl> wrote on Sat, 17 Jul 2004
> 23:08:59 +0200:
>
> The font-lock function matcher wasn't (and possibly still isn't) fully
> documented in the elisp manual. The following may be helpful:
>
> When FUNCTION is called, it receives one argument, the limit of the
> search. Its search should start at point and not extend beyond the
> limit. FUNCTION should return non-`nil' if it succeeds, and set the
> match data to describe the match that was found. FUNCTION will be
> called repeatedly with the same limit, and with point where the
> previous invocation left it, until it fails. It need not reset
> point to a sensible value on failure.
>
Yeah, I found that passage. It was useful, up to a point. What I have
now, works slightly better. I found out that I need to find words and
calculate their scrabble-score.
Is it true then that I need to keep on searching forward until I find a
word whose scrabble score matches 6 (or until I reach limit)? If so, I'm
having trouble when point is at (- limit 1). When that's the case, the
matcher function is called repeatedly without stopping.
>
>>I'm looking for a way to fontify words accoriding to their scrabble
>>score. So if a word would score 6 points in american scrabble, it
>>should get a certain font-locking.
>
>
>>Currently, I have the following elisp, but it does not work.
>
>
> Have you discovered the joys of edebug, yet? If not, I thoroughly
> recommend you to invest a few hours learning it. For example, put point
> inside `scrabble-6-matcher' and do C-u C-M-x to instrument it for edebug.
Normally I call M-x edebug-defun. How is this different?
> Then call the function directly with M-: (scrabble-6-matcher 200).
> Enjoy!
>
> A hint: if you're going to be using edebug within "live" font-lock
> routines, do this first: M-: (setq font-lock-support-mode nil).
> Otherwise the jit-lock timer routine will kick in 3 seconds after you've
> starting looking at your function, destroying your concentration and
> peace of mind.
I tried it without the (setq ...) It didn't destroy anything. In fact,
it didn't do anything at all. Although, come to think of it, I got a few
malloc error messages from emacs in my console. But maybe that is
because I'm using a cvs emacs from a week ago.
>
> As for locking the system, I suspect you've got into an infinite loop
> with your regular expression: (re-search-forward "\\([a-z]\\)*" limit t).
> This regexp will match any sequence of lower case letters, including an
> empty one. ;-(. Probably you really want something more like
> "\\([a-z]\\)+". Then ask yourself whether you really want the "+"
> _outside_ the grouping parentheses. ;-)
Thanks, currently I'm having a bit more success with "\\<\\(.+?\\)\\>
>
> Have fun!
Thanks! This /is/ fun! It's my summer holiday project. Done when I do
not have to decorate my house (you know how spouses are ;-) )
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-25 19:55 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 [this message]
2004-07-26 20:59 ` Stefan Monnier
2004-07-26 21:00 ` Stefan Monnier
2004-07-27 18:12 ` Arjan Bos
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='ce13el$l9g$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).