]> code.delx.au - gnu-emacs-elpa/blobdiff - chess.el
chess-perft.el: move generator testing.
[gnu-emacs-elpa] / chess.el
index 3fbda11969074dd1af95391813090e618535f929..541715db52562c8e7496c93ba4ef8f44adf67c4d 100644 (file)
--- a/chess.el
+++ b/chess.el
@@ -7,10 +7,10 @@
 ;; Version: 2.0
 ;; Keywords: games
 ;; Author: John Wiegley <johnw@gnu.org>
-;; Maintainer: John Wiegley <johnw@gnu.org>
+;; Maintainer: Mario Lang <mlang@delysid.org>
 ;; Description: Play chess in Emacs
-;; URL: http://www.gci-net.com/~johnw/Emacs/packages/chess.tar.gz
-;; Compatibility: Emacs20, Emacs21, XEmacs21
+;; URL: http://emacs-chess.sourceforge.net/
+;; Compatibility: Emacs21
 
 ;; This file is not part of GNU Emacs.
 
@@ -41,7 +41,7 @@
 ;;
 ;; To just get a chessboard up, put the following in your .emacs file:
 ;;
-;;   (add-to-list 'load-list "<the path to Emacs Chess>")
+;;   (add-to-list 'load-path "<the path to Emacs Chess>")
 ;;
 ;;   (autoload 'chess "chess" "Play a game of chess" t)
 ;;
@@ -81,7 +81,7 @@
   "An Emacs chess playing program."
   :group 'games)
 
-(defconst chess-version "2.0a15"
+(defconst chess-version "2.0b6"
   "The version of the Emacs chess program.")
 
 (defcustom chess-default-display
@@ -96,8 +96,9 @@ not available."
   '((chess-sound chess-announce)
     chess-autosave
     chess-clock
-    chess-kibitz
-    chess-chat)
+    ;;chess-kibitz   jww (2002-04-30): not fully supported yet
+    ;;chess-chat
+    )
   "Modules to be used when starting a chess session.
 A sublist indicates a series of alternatives, if the first is not
 available.
@@ -106,7 +107,10 @@ These can do just about anything."
   :group 'chess)
 
 (defcustom chess-default-engine
-  '(chess-crafty chess-gnuchess chess-phalanx)
+  '(chess-crafty
+    chess-stockfish chess-glaurung chess-fruit
+    chess-gnuchess chess-phalanx
+    chess-ai)
   "Default engine to be used when starting a chess session.
 A list indicates a series of alternatives if the first engine is not
 available."
@@ -118,6 +122,12 @@ available."
   :type 'string
   :group 'chess)
 
+(and (fboundp 'font-lock-add-keywords)
+     (font-lock-add-keywords
+      'emacs-lisp-mode
+      '(("(\\(chess-error\\)\\>"              1 font-lock-warning-face)
+       ("(\\(chess-with-current-buffer\\)\\>" 1 font-lock-keyword-face))))
+
 (defun chess--create-display (module game my-color disable-popup)
   (let ((display (chess-display-create game module my-color)))
     (when display
@@ -138,6 +148,8 @@ available."
       engine)))
 
 (defun chess-create-modules (module-list create-func &rest args)
+  "Create modules from MODULE-LIST with CREATE-FUNC and ARGS.
+If an element of MODULE-LIST is a sublist, treat it as alternatives."
   (let (objects)
     (dolist (module module-list)
       (let (object)
@@ -147,7 +159,9 @@ available."
          ;; this module is actually a list, which means keep trying
          ;; until we find one that works
          (while module
-           (if (setq object (apply create-func (car module) args))
+           (if (setq object (condition-case nil
+                                (apply create-func (car module) args)
+                              (error nil)))
                (progn
                  (push object objects)
                  (setq module nil))
@@ -155,12 +169,15 @@ available."
     (nreverse objects)))
 
 (chess-message-catalog 'english
-  '((no-engines-found . "Could not find any chess engines to play against; install gnuchess!")))
+  '((no-engines-found
+     . "Could not find any chess engines to play against; install gnuchess!")))
 
 ;;;###autoload
 (defun chess (&optional engine disable-popup engine-response-handler
                        &rest engine-ctor-args)
-  "Start a game of chess, playing against ENGINE (a module name)."
+  "Start a game of chess, playing against ENGINE (a module name).
+With prefix argument, prompt for the engine to play against.
+Otherwise use `chess-default-engine' to determine the engine."
   (interactive
    (list
     (if current-prefix-arg
@@ -185,16 +202,20 @@ available."
     (when (car objects)
       (mapc 'chess-display-update objects)
       (chess-module-set-leader (car objects))
-      (chess-display-popup (car objects)))
+      (unless disable-popup
+       (chess-display-popup (car objects))))
 
     (nconc objects (chess-create-modules chess-default-modules
                                         'chess-module-create game))
 
     (push (unless (eq engine 'none)
-           (car (chess-create-modules (list (or engine chess-default-engine))
-                                      'chess--create-engine game
-                                      engine-response-handler
-                                      engine-ctor-args)))
+           (car ;(condition-case nil
+                    (chess-create-modules (list (or engine chess-default-engine))
+                                          'chess--create-engine game
+                                          engine-response-handler
+                                          engine-ctor-args)
+                  ;  (error nil))
+           ))
          objects)
 
     (unless (car objects)