* riece-hangman.el (riece-hangman-word): Check killed-buffer or
authorkaoru <kaoru>
Fri, 4 Jun 2004 09:57:06 +0000 (09:57 +0000)
committerkaoru <kaoru>
Fri, 4 Jun 2004 09:57:06 +0000 (09:57 +0000)
not.  Fix random number generation logic.

lisp/ChangeLog
lisp/riece-hangman.el

index 66b3c6e..37df294 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-04  TAKAHASHI Kaoru  <kaoru@kaisei.org>
+
+       * riece-hangman.el (riece-hangman-word): Check killed-buffer or
+       not.  Fix random number generation logic.
+
 2004-06-03  Daiki Ueno  <ueno@unixuser.org>
 
        * riece-server.el (riece-open-server): When password input is
index 0f79838..c4fd54c 100644 (file)
@@ -96,7 +96,8 @@ This function is for internal use only."
 (defun riece-hangman-word ()
   "Return random word.
 The wordlist is read from `riece-hangman-words-file'."
-  (unless riece-hangman-words-buffer
+  (unless (and riece-hangman-words-buffer
+              (buffer-name riece-hangman-words-buffer))
     (setq riece-hangman-words-buffer (generate-new-buffer " *riece-hangman*"))
     (save-excursion
       (set-buffer riece-hangman-words-buffer)
@@ -106,7 +107,7 @@ The wordlist is read from `riece-hangman-words-file'."
        (delete-non-matching-lines "^[a-z][a-z][a-z][a-z][a-z][a-z]+"))))
   (save-excursion
     (set-buffer riece-hangman-words-buffer)
-    (goto-char (% (1+ (random)) (buffer-size)))
+    (goto-char (1+ (random (buffer-size))))
     (if (eobp)
        (beginning-of-line -1)
       (beginning-of-line))