From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Arjan Bos Newsgroups: gmane.emacs.help Subject: Re: font-lock function matcher sample Date: Wed, 04 Aug 2004 20:56:00 +0200 Organization: Planet Internet Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: Reply-To: Arjan.Bos@ISeeYou.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1091645812 28611 80.91.224.253 (4 Aug 2004 18:56:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 4 Aug 2004 18:56:52 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 04 20:56:39 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BsQwJ-0006de-00 for ; Wed, 04 Aug 2004 20:56:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BsQzo-0003wk-CA for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Aug 2004 15:00:16 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!feed.news.tiscali.de!newsfeed01.sul.t-online.de!t-online.de!newsfeeds.phibee.net!newsfeeder.wxs.nl!textnews.wxs.nl!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 85 Original-NNTP-Posting-Host: ip51cd7a2f.adsl-surfen.hetnet.nl Original-X-Trace: reader11.wxs.nl 1091646216 21927 81.205.122.47 (4 Aug 2004 19:03:36 GMT) Original-X-Complaints-To: abuse@planet.nl Original-NNTP-Posting-Date: 4 Aug 2004 19:03:36 GMT User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en In-Reply-To: Original-Xref: shelby.stanford.edu gnu.emacs.help:124652 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:19985 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19985 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! > > > > 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