help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: font-lock function matcher sample


From: Stefan Monnier
Subject: Re: font-lock function matcher sample
Date: Wed, 04 Aug 2004 19:48:10 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>>>> 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

But if it is t and score-match is not equal, than you go around the loop
once more where found will be reset to either nil or t depending on whether
there are more words to find.
So I still don't understand the problem.

> (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))

This will always return nil because if found is non-nil, we don't exit
the loop.

> 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.

I strongly doubt such problems would be specific to Mac OS X (tho they may
have more serious implication since C-g tends not to work as well).

>> 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").

If jit-lock-mode is turned off, edebug-defun should work just fine (at
least that's been my experience).  With jit-lock, I've had it work and not
work at different points in time.


        Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]