(read_minibuf): Clean up the binding stack if
[bpt/emacs.git] / lisp / play / solitaire.el
index c3a4b4f..5b00718 100644 (file)
 
 ;;; Code:
 
+(defgroup solitaire nil
+  "Game of solitaire."
+  :prefix "solitaire-"
+  :group 'games)
+
 (defvar solitaire-mode-map nil
   "Keymap for playing solitaire.")
 
+(defcustom solitaire-mode-hook nil
+  "Hook to run upon entry to solitaire."
+  :type 'hook
+  :group 'solitaire)
+
 (if solitaire-mode-map
     ()
   (setq solitaire-mode-map (make-sparse-keymap))
@@ -116,10 +126,12 @@ The usual mnemonic keys move the cursor around the board; in addition,
 (defvar solitaire-end-x nil)
 (defvar solitaire-end-y nil)
 
-(defvar solitaire-auto-eval t
+(defcustom solitaire-auto-eval t
   "*Non-nil means check for possible moves after each major change.
 This takes a while, so switch this on if you like to be informed when
-the game is over, or off, if you are working on a slow machine.")
+the game is over, or off, if you are working on a slow machine."
+  :type 'boolean
+  :group 'solitaire)
 
 (defconst solitaire-valid-directions
   '(solitaire-left solitaire-right solitaire-up solitaire-down))
@@ -134,13 +146,13 @@ Move around the board using the cursor keys.
 Move stones using \\[solitaire-move] followed by a direction key.
 Undo moves using \\[solitaire-undo].
 Check for possible moves using \\[solitaire-do-check].
-\(The variable solitaire-auto-eval controls whether to automatically
+\(The variable `solitaire-auto-eval' controls whether to automatically
 check after each move or undo)
 
 What is Solitaire?
 
 I don't know who invented this game, but it seems to be rather old and
-its origin seems be northern Africa.  Here's how to play:
+its origin seems to be northern Africa.  Here's how to play:
 Initially, the board will look similar to this:
 
        Le Solitaire             
@@ -321,20 +333,18 @@ list containing three numbers: starting field, skipped field (from
 which a stone will be taken away) and target."
 
   (save-excursion
-    (let (move)
-      (fset 'move movesymbol)
-      (if (memq movesymbol solitaire-valid-directions)
-         (let ((start (point))
-               (skip (progn (move) (point)))
-               (target (progn (move) (point))))
-           (if (= skip target)
-               "Off Board!"
-             (if (or (/= ?o (char-after start))
-                     (/= ?o (char-after skip))
-                     (/= ?. (char-after target)))
-                 "Wrong move!"
-               (list start skip target))))
-       "Not a valid direction"))))
+    (if (memq movesymbol solitaire-valid-directions)
+       (let ((start (point))
+             (skip (progn (funcall movesymbol) (point)))
+             (target (progn (funcall movesymbol) (point))))
+         (if (= skip target)
+             "Off Board!"
+           (if (or (/= ?o (char-after start))
+                   (/= ?o (char-after skip))
+                   (/= ?. (char-after target)))
+               "Wrong move!"
+             (list start skip target))))
+      "Not a valid direction")))
 
 (defun solitaire-move (dir)
   "Pseudo-prefix command to move a stone in Solitaire."