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: Tue, 27 Jul 2004 20:12:23 +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 1090952635 31735 80.91.224.253 (27 Jul 2004 18:23:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 27 Jul 2004 18:23:55 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 27 20:23:42 2004 Return-path: Original-Received: from mail-relay.eunet.no ([193.71.71.242]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BpWc2-00024e-00 for ; Tue, 27 Jul 2004 20:23:42 +0200 Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by mail-relay.eunet.no (8.12.11/8.12.11/GN) with ESMTP id i6RINV8t076362 for ; Tue, 27 Jul 2004 20:23:38 +0200 (CEST) (envelope-from help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org) Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BpWYk-0002gw-8x for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Jul 2004 14:20:18 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!news.ks.uiuc.edu!news.glorb.com!news.zanker.org!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeeder.wxs.nl!textnews.wxs.nl!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-NNTP-Posting-Host: ip51cd7a2f.adsl-surfen.hetnet.nl Original-X-Trace: reader10.wxs.nl 1090952192 12868 81.205.122.47 (27 Jul 2004 18:16:32 GMT) Original-X-Complaints-To: abuse@planet.nl Original-NNTP-Posting-Date: 27 Jul 2004 18:16:32 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:124503 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:19838 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19838 Stefan Monnier wrote: > Basically calling FUNCTION as in > > (FUNCTION lim) > > should behave similarly (as far as mach-data, point, and > return value go) to > > (re-search-forward RE lim t) > > Thanks, that matches my ideas. 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'. Otherwise I calculate the scrabble score for it and if that matches the asked for scrabble score (say 6) then I return `t'. In all other cases, I return `nil' like in: (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." (if (and (re-search-forward beatnik-font-matcher-regexp limit t) (= (beatnik-last-word-score) score-match)) (progn (setq beatnik-last-match (list (match-string-no-properties 1) limit score-match (point))) t) ;; else (if (equal (list (match-string-no-properties 1) limit score-match (point)) beatnik-last-match) ;; we already found it, return nil nil ;; else (while (and (re-search-forward beatnik-font-matcher-regexp limit t) (not (= (beatnik-last-word-score) score-match)))) (if (= (beatnik-last-word-score) score-match) (progn (setq beatnik-last-match (list (match-string-no-properties 1) limit score-match (point))) t) ;; else nil)))) Stephan and Alan, many thanks for helping me out. Maybe your comments should find their way to the doc-string or the info pages? Thanks! Arjan -- -- If you really want to contact me, then replace the "I see you" text by its three letter accronym, ICU. Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett