From: Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl>
Subject: Re: font-lock function matcher sample
Date: Wed, 04 Aug 2004 20:56:00 +0200 [thread overview]
Message-ID: <cerbu8$ld7$1@reader11.wxs.nl> (raw)
In-Reply-To: <jwvhdrk9isx.fsf-monnier+gnu.emacs.help@gnu.org>
Stefan Monnier wrote:
>>>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))
>
>
>>This is almost what I intended. This sets `found' to `t' even when the asked
>>for scrabble score via (beatnik-last-word-score) isn't found.
>
>
> Huh? The while loop is only exited if found is nil or if
> (beatnik-last-word-score) is equal to score-match, AFAICT.
You're right about the while loop, but still you're setting `found' to
`t' even when the word doesn't equal score-match. And it is `found' that
is returned
>
> I don't understand the problem you're referring to.
>
>
>>But when I move the `and' into the `setq' it doesn't work, meaning that it
>>locks itself fontifying.
>
> This code seems to be exactly equl to the one above.
Oops, I meant:
(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)
;; doesn't work:
(while (setq found (and (re-search-forward
beatnik-font-matcher-regexp limit t))
(/= (beatnik-last-word-score) score-match)))
found))
>
>
>>Well, what I really missed was a sample function. I think the one you posted
>>could well serve as a template. The info page ((elisp)Search-based
>>Fontification.) had the needed input and output for the defun, but the
>>doc-string for `font-lock-defaults' had neither. Maybe it could point to the
>>info page?
>
>
> I've changed the docstring to mention the fact that point is expected to
> move, and to mention that it should all behave like re-search-forward.
Great! The World of Emacs gained at least this from your effort!
>
>
<snip />
>
> These bugs should be reported and fixed (but there's no point reporting them
> unless you can provide a reliable recipe to reproduce them or unless you can
> verify that they are still present in the CVS version of Emacs).
I agree that bugs should be reported and fixed. But I do not really have
a reliable testcase to reproduce them. Especially since RMS himself
stated recently that he cannot check errors on MacOS X since he doesn't
have the hardware.
>
> But even if they get fixed, I agree that debugging font-lock-keywords
> settings is painful. Turning off jit-lock-mode can help, tho.
I couldn't even get edebug-defun to get started, so I did it the
old-fashioned way by using (message "string").
Arjan
--
--
If you really want to contact me, then replace the "I see you" text by
its three letter accronym, HetNet.
Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett
next prev parent reply other threads:[~2004-08-04 18:56 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
2004-08-03 18:09 ` Arjan Bos
2004-08-03 18:39 ` Stefan Monnier
2004-08-04 18:56 ` Arjan Bos [this message]
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='cerbu8$ld7$1@reader11.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.
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.