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: font-lock function matcher sample Date: Sat, 17 Jul 2004 23:08:59 +0200 Organization: Planet Internet Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: 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 1090099704 11284 80.91.224.253 (17 Jul 2004 21:28:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 17 Jul 2004 21:28:24 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 17 23:28:09 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 1Blwj0-0004gs-00 for ; Sat, 17 Jul 2004 23:28:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Blwl8-0003Fc-JM for geh-help-gnu-emacs@m.gmane.org; Sat, 17 Jul 2004 17:30:18 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news2.telebyte.nl!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: 53 Original-NNTP-Posting-Host: ip51cd7a2f.adsl-surfen.hetnet.nl Original-X-Trace: reader13.wxs.nl 1090098524 24950 81.205.122.47 (17 Jul 2004 21:08:44 GMT) Original-X-Complaints-To: abuse@planet.nl Original-NNTP-Posting-Date: 17 Jul 2004 21:08:44 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 Original-Xref: shelby.stanford.edu gnu.emacs.help:124361 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:19697 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19697 Hi, Could anyone of you please post a sample for a font-lock function matcher? I'm looking for a way to fontify words accoriding to their scrabble score. So if a word would score 6 points in american scrabble, it should get a certain font-locking. Currently, I have the following elisp, but it does not work. I've been looking at some samples from the emacs lisp directories, but failed to work out the pattern. Also the info node on font-locking and the various font-locking doc-strings were helpful, but not helpful enough. My elisp swings between locking emacs (presumably on font-locking) and no font-locking at all. (this of course when I twiddle around with it) (defvar scrabble-font-lock-keywords (list '(scrabble-6-matcher (1 font-lock-warning-face)) )) (defun scrabble-6-matcher (limit) "returns t when the scrabble score of a word is 6." (if (and (re-search-forward "\\([a-z]\\)*" limit t) (< (scrabble-last-word-score) 5)) (progn (set-match-data (list (match-beginning 1) (match-end 1) (match-beginning 1) (match-end 1) nil nil))) ;; else (set-match-data (list (match-beginning 1) (match-end 1) nil nil (match-beginning 1) (match-end 1))) t)) (defun scrabble-last-word-score () "" 5) TIA, 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