(mpuz-random-puzzle): Fix potential lockup when
[bpt/emacs.git] / lisp / play / mpuz.el
index 22d4216..5cb2ed0 100644 (file)
@@ -1,6 +1,7 @@
 ;;; mpuz.el --- multiplication puzzle for GNU Emacs
 
-;; Copyright (C) 1990, 2002, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Philippe Schnoebelen <phs@lsv.ens-cachan.fr>
 ;; Overhauled: Daniel Pfeiffer <occitan@esperanto.org>
@@ -62,31 +63,23 @@ t means never ding, and `error' means only ding on wrong input."
     (t (:bold t)))
   "*Face to use for letters to be solved."
   :group 'mpuz)
-;; backward-compatibility alias
-(put 'mpuz-unsolved-face 'face-alias 'mpuz-unsolved)
 
 (defface mpuz-solved
   '((((class color)) (:foreground "green1" :bold t))
     (t (:bold t)))
   "*Face to use for solved digits."
   :group 'mpuz)
-;; backward-compatibility alias
-(put 'mpuz-solved-face 'face-alias 'mpuz-solved)
 
 (defface mpuz-trivial
   '((((class color)) (:foreground "blue" :bold t))
     (t (:bold t)))
   "*Face to use for trivial digits solved for you."
   :group 'mpuz)
-;; backward-compatibility alias
-(put 'mpuz-trivial-face 'face-alias 'mpuz-trivial)
 
 (defface mpuz-text
   '((t (:inherit variable-pitch)))
   "*Face to use for text on right."
   :group 'mpuz)
-;; backward-compatibility alias
-(put 'mpuz-text-face 'face-alias 'mpuz-text)
 
 \f
 ;; Mpuz mode and keymaps
@@ -269,8 +262,9 @@ You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
   (fillarray mpuz-board nil)           ; erase the board
   ;; A,B,C,D & E, are the five rows of our multiplication.
   ;; Choose random values, discarding cases with leading zeros in C or D.
-  (let* ((A (+ 112 (random 888)))
-        (min (1+ (/ 1000 A)))
+  (let* ((A (if mpuz-allow-double-multiplicator (+ 112 (random 888))
+             (+ 125 (random 875))))
+        (min (1+ (/ 999 A)))
         (B1 (+ min (random (- 10 min))))
         B2 C D E)
     (while (if (= B1 (setq B2 (+ min (random (- 10 min)))))
@@ -408,7 +402,7 @@ You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
 (defun mpuz-offer-abort ()
   "Ask if user wants to abort current puzzle."
   (interactive)
-  (if (y-or-n-p "Abort game ")
+  (if (y-or-n-p "Abort game? ")
       (let ((buf (mpuz-get-buffer)))
        (message "Mult Puzzle aborted.")
        (setq mpuz-in-progress nil
@@ -452,7 +446,7 @@ You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
               (mpuz-ding t))
              (t
               (mpuz-try-proposal letter-char digit-char))))
-    (if (y-or-n-p "Start a new game ")
+    (if (y-or-n-p "Start a new game? ")
        (mpuz-start-new-game)
       (message "OK. I won't."))))
 
@@ -497,7 +491,7 @@ You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
                               (t                       "not serious.")))))
     (message message)
     (sit-for 4)
-    (if (y-or-n-p (concat message "  Start a new game "))
+    (if (y-or-n-p (concat message "  Start a new game? "))
        (mpuz-start-new-game)
       (message "Good Bye!"))))