From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: font-lock function matcher sample Date: Tue, 27 Jul 2004 18:36:44 GMT Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1090953466 1436 80.91.224.253 (27 Jul 2004 18:37:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 27 Jul 2004 18:37:46 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 27 20:37:20 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 1BpWpE-0003IM-00 for ; Tue, 27 Jul 2004 20:37:20 +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 i6RIb8Xr082294 for ; Tue, 27 Jul 2004 20:37:15 +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 1BpWs1-0007Wd-Gi for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Jul 2004 14:40:13 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn14feed!worldnet.att.net!207.35.177.252!nf3.bellglobal.com!snoopy.risq.qc.ca!charlie.risq.qc.ca!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 35 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-NNTP-Posting-Host: 132.204.24.84 Original-X-Complaints-To: abuse@umontreal.ca Original-X-Trace: charlie.risq.qc.ca 1090953404 132.204.24.84 (Tue, 27 Jul 2004 14:36:44 EDT) Original-NNTP-Posting-Date: Tue, 27 Jul 2004 14:36:44 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:124504 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:19839 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19839 > 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'. The fact that you need to compare with last search indicates that there's something fishy with your code. > (while (and (re-search-forward beatnik-font-matcher-regexp limit t) > (not (= (beatnik-last-word-score) score-match)))) Here you lose the information about whether the search succeeded or failed which the source of your problems. I.e. if the search fails immediately (typically you've hit LIMIT) then (= (beatnik-last-word-score) score-match) will be true and your code will screw up. 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)) > Stephan and Alan, many thanks for helping me out. Maybe your comments > should find their way to the doc-string or the info pages? >>From what I can see, your problems had nothing to do understanding how font-lock works. But if you have a concrete suggestion for how to change the docstring, patches are welcome. Stefan