From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: font-lock function matcher sample
Date: Tue, 27 Jul 2004 18:36:44 GMT [thread overview]
Message-ID: <jwv4qntcnqn.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: ce6660$ci4$1@reader10.wxs.nl
> 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)))
found))
> 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.
Stefan
next prev parent reply other threads:[~2004-07-27 18:36 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
2004-07-27 18:36 ` Stefan Monnier [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv4qntcnqn.fsf-monnier+gnu.emacs.help@gnu.org \
--to=monnier@iro.umontreal.ca \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.