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: Arjan Bos
Subject: Re: font-lock function matcher sample
Date: Wed, 04 Aug 2004 20:56:00 +0200
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7) Gecko/20040616

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


reply via email to

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