gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] [patch] fontlock for gnugo.el


From: Joe Corneli
Subject: [gnugo-devel] [patch] fontlock for gnugo.el
Date: Wed, 19 May 2004 18:50:13 -0500

This patch provides fontification in gnugo-board-mode (provided in
the package gnugo.el that ships with GNU Go).  Colors are currently
tuned for use with a black background.

Thanks Thi for your help on this; I also borrowed a little from your
ricette-mode.

The comments contain a question and a suggestion for future work.

diff -c /Users/arided/gnugo-3.4/interface/gnugo.el 
/Users/arided/gnugo-3.4/interface/gnugo-hacked.el
*** /Users/arided/gnugo-3.4/interface/gnugo.el     Mon Jul 21 11:33:19 2003
--- /Users/arided/gnugo-3.4/interface/gnugo-hacked.el  Wed May 19 13:41:33 2004
***************
*** 148,153 ****
--- 148,193 ----
    (gnugo-progn '((orig . switch-to-buffer)))
    (delete-other-windows))
  
+ (defmacro gnugo-new-face (name color doc)
+   (let ((prop (intern (concat "gnugo-" (symbol-name name) "-face"))))
+     `(progn
+        (defvar  ,prop ',prop)
+        (defface ,prop '((t (:foreground ,(symbol-name color)))) ,doc))))
+ 
+ (gnugo-new-face plain purple "Face for plain text in `gnugo-board-mode'.")
+ (gnugo-new-face star yellow "Face for stars in `gnugo-board-mode'.")
+ (gnugo-new-face dot grey30 "Face for dots in `gnugo-board-mode'.")
+ 
+ (defcustom gnugo-font-lock-keywords
+   (list '("X" . font-lock-builtin-face)
+         '("\\(O\\)" 1 font-lock-type-face)
+         '("[0-9]+" . font-lock-comment-face)
+         '("[()]" . font-lock-warning-face)
+         '("+"  . gnugo-star-face)
+         '("."  . gnugo-dot-face)
+         ;; Overrides begin here
+         ;; TODO: make this work for differently-sized boards
+         '("\\(A B C D E F G H J K L M N O P Q R S T\\)" 
+           (1 font-lock-comment-face t t))
+         '(":\\(.*\\)" 
+           (1 font-lock-variable-name-face t t))
+         '("\\(White (\\)" 
+           (1 gnugo-plain-face t t))
+         '("\\(Black (\\)" 
+           (1 gnugo-plain-face t t))
+         '("\\() has captured [0-9]+ pieces\\)" 
+           (1 gnugo-plain-face t t))
+         '("\\(white(\\)" 
+           (1 gnugo-plain-face t t))
+         '("\\(black(\\)" 
+           (1 gnugo-plain-face t t))
+         '("\\():\\)" 
+           (1 gnugo-plain-face t t))
+         ;; I'm not sure why this text shows up in the buffer.
+         '("\\(EMACS.*\\)" 
+           (1 gnugo-plain-face t t)))
+   "Font lock for `gnugo-board-mode'.")
+ 
  (defun gnugo-board-mode ()
    "In this mode, keys do not self insert.
  Here are the default keybindings:
***************
*** 170,175 ****
--- 210,217 ----
            directly to the inferior GNUGO process."
    (kill-all-local-variables)
    (use-local-map gnugo-board-mode-map)
+   (set (make-local-variable 'font-lock-defaults)
+   '(gnugo-font-lock-keywords))
    (setq major-mode 'gnugo-board-mode)
    (setq mode-name "GNUGO Board"))
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]