all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* font-lock function matcher sample
@ 2004-07-17 21:08 Arjan Bos
  2004-07-25  8:26 ` Alan Mackenzie
  0 siblings, 1 reply; 14+ messages in thread
From: Arjan Bos @ 2004-07-17 21:08 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-08-05 19:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-17 21:08 font-lock function matcher sample Arjan Bos
2004-07-25  8:26 ` Alan Mackenzie
2004-07-25 19:55   ` Arjan Bos
2004-07-26 20:59     ` Stefan Monnier
2004-07-26 21:00     ` Stefan Monnier
2004-07-27 18:12       ` Arjan Bos
2004-07-27 18:36         ` Stefan Monnier
2004-08-03 18:09           ` Arjan Bos
2004-08-03 18:39             ` Stefan Monnier
2004-08-04 18:56               ` Arjan Bos
2004-08-04 19:48                 ` Stefan Monnier
2004-08-04 20:00                   ` Arjan Bos
2004-08-04 20:08                     ` Stefan Monnier
2004-08-05 19:16                       ` Arjan Bos

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.