Don't use old-style backquote in doc/ptexinfmt.el.
[riece] / lisp / riece-hangman.el
index d049e0e..426935e 100644 (file)
@@ -1,4 +1,4 @@
-;;; riece-hangman.el --- hangman
+;;; riece-hangman.el --- allow channel members to play the hangman game
 ;; Copyright (C) 1998-2004 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;; Copyright (C) 1998-2004 Daiki Ueno
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 
 ;;; Commentary:
 
-;; To use, add the following line to your ~/.riece/init.el:
-;; (add-to-list 'riece-addons 'riece-hangman)
+;; NOTE: This is an add-on module for Riece.
 
 ;;; Code:
 
 
 ;;; Code:
 
@@ -34,7 +33,7 @@
 (require 'riece-server)
 
 (defgroup riece-hangman nil
 (require 'riece-server)
 
 (defgroup riece-hangman nil
-  "Interface to hangman.el."
+  "Allow channel members to play the hangman game."
   :prefix "riece-"
   :group 'riece)
 
   :prefix "riece-"
   :group 'riece)
 
 (defvar riece-hangman-player-context-alist nil)
 (defvar riece-hangman-words-buffer nil)
 
 (defvar riece-hangman-player-context-alist nil)
 (defvar riece-hangman-words-buffer nil)
 
-(defvar riece-hangman-enabled nil)
-
 (defconst riece-hangman-description
 (defconst riece-hangman-description
-  "Allow users in channel to play classic textual game \"hangman\"")
+  "Allow channel members to play the hangman game.")
 
 (put 'riece-hangman 'riece-addon-default-disabled t)
 
 
 (put 'riece-hangman 'riece-addon-default-disabled t)
 
@@ -99,14 +96,12 @@ The wordlist is read from `riece-hangman-words-file'."
   (unless (and riece-hangman-words-buffer
               (buffer-name riece-hangman-words-buffer))
     (setq riece-hangman-words-buffer (generate-new-buffer " *riece-hangman*"))
   (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)
+    (with-current-buffer riece-hangman-words-buffer
       (buffer-disable-undo)
       (insert-file-contents riece-hangman-words-file)
       (let ((case-fold-search nil))
        (delete-non-matching-lines "^[a-z][a-z][a-z][a-z][a-z][a-z]+"))))
       (buffer-disable-undo)
       (insert-file-contents riece-hangman-words-file)
       (let ((case-fold-search nil))
        (delete-non-matching-lines "^[a-z][a-z][a-z][a-z][a-z][a-z]+"))))
-  (save-excursion
-    (set-buffer riece-hangman-words-buffer)
+  (with-current-buffer riece-hangman-words-buffer
     (goto-char (1+ (random (buffer-size))))
     (if (eobp)
        (beginning-of-line -1)
     (goto-char (1+ (random (buffer-size))))
     (if (eobp)
        (beginning-of-line -1)
@@ -141,7 +136,7 @@ The wordlist is read from `riece-hangman-words-file'."
               "")))))
 
 (defun riece-hangman-after-privmsg-hook (prefix string)
               "")))))
 
 (defun riece-hangman-after-privmsg-hook (prefix string)
-  (if riece-hangman-enabled
+  (if (get 'riece-hangman 'riece-addon-enabled)
       (let* ((user (riece-prefix-nickname prefix))
             (parameters (riece-split-parameters string))
             (targets (split-string (car parameters) ","))
       (let* ((user (riece-prefix-nickname prefix))
             (parameters (riece-split-parameters string))
             (targets (split-string (car parameters) ","))
@@ -228,12 +223,11 @@ The wordlist is read from `riece-hangman-words-file'."
 (defun riece-hangman-insinuate ()
   (add-hook 'riece-after-privmsg-hook 'riece-hangman-after-privmsg-hook))
 
 (defun riece-hangman-insinuate ()
   (add-hook 'riece-after-privmsg-hook 'riece-hangman-after-privmsg-hook))
 
-(defun riece-hangman-enable ()
-  (random t)
-  (setq riece-hangman-enabled t))
+(defun riece-hangman-uninstall ()
+  (remove-hook 'riece-after-privmsg-hook 'riece-hangman-after-privmsg-hook))
 
 
-(defun riece-hangman-disable ()
-  (setq riece-hangman-enabled nil))
+(defun riece-hangman-enable ()
+  (random t))
 
 (provide 'riece-hangman)
 
 
 (provide 'riece-hangman)