]> code.delx.au - gnu-emacs/blobdiff - lisp/play/dunnet.el
Simplify by using `define-derived-mode'.
[gnu-emacs] / lisp / play / dunnet.el
index 402a3d96769b00a6c8e2396efe0da1b575fa85fc..f5f8bd7ed4401f63e96aa93919fb04808f3dd7fe 100644 (file)
@@ -1,6 +1,7 @@
-;;; dunnet.el --- text adventure for Emacs
+;;; dunnet.el --- text adventure for Emacs -*-  byte-compile-warnings: nil -*-
 
-;; Copyright (C) 1992, 1993, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Ron Schnell <ronnie@driver-aces.com>
 ;; Created: 25 Jul 1992
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +21,7 @@
 ;; GNU General Public License for more details.
 
 ;; 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.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
   :type 'file
   :group 'dunnet)
 
-(if nil
-    (eval-and-compile (setq byte-compile-warnings nil)))
-
-(eval-when-compile
- (require 'cl))
-
 ;;;; Mode definitions for interactive mode
 
-(defun dun-mode ()
+(define-derived-mode dun-mode text-mode "Dungeon"
   "Major mode for running dunnet."
-  (interactive)
-  (text-mode)
   (make-local-variable 'scroll-step)
-  (setq scroll-step 2)
-  (use-local-map dungeon-mode-map)
-  (setq major-mode 'dun-mode)
-  (setq mode-name "Dungeon"))
+  (setq scroll-step 2))
 
 (defun dun-parse (arg)
   "Function called when return is pressed in interactive mode to parse line."
   (interactive "*p")
   (beginning-of-line)
-  (setq beg (+ (point) 1))
-  (end-of-line)
-  (if (and (not (= beg (point))) (not (< (point) beg))
-          (string= ">" (buffer-substring (- beg 1) beg)))
-      (progn
-       (setq line (downcase (buffer-substring beg (point))))
-       (princ line)
-       (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
-           (dun-mprinc "I don't understand that.\n")))
+  (let ((beg (1+ (point)))
+        line)
+    (end-of-line)
+    (if (and (not (= beg (point))) (not (< (point) beg))
+             (string= ">" (buffer-substring (- beg 1) beg)))
+        (progn
+          (setq line (downcase (buffer-substring beg (point))))
+          (princ line)
+          (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
+              (dun-mprinc "I don't understand that.\n")))
     (goto-char (point-max))
-    (dun-mprinc "\n"))
-    (dun-messages))
+    (dun-mprinc "\n")))
+  (dun-messages))
 
 (defun dun-messages ()
   (if dun-dead
@@ -939,7 +928,7 @@ or more clues in here):
 - If you go down a hole in the floor without an aid such as a ladder,
   you probably won't be able to get back up the way you came, if at all.
 
-- To run this game in batch mode (no emacs window), use:
+- To run this game in batch mode (no Emacs window), use:
      emacs -batch -l dunnet
 NOTE: This game *should* be run in batch mode!
 
@@ -1308,7 +1297,7 @@ for a moment, then straighten yourself up.
       (condition-case nil
          (dun-rot13)
        (error (yank)))
-      (eval-current-buffer)
+      (eval-buffer)
       (kill-buffer (current-buffer)))
       (switch-to-buffer old-buffer)
     result))
@@ -1366,9 +1355,8 @@ for a moment, then straighten yourself up.
 (setq dun-current-room 1)
 (setq dun-exitf nil)
 (setq dun-badcd nil)
-(defvar dungeon-mode-map nil)
-(setq dungeon-mode-map (make-sparse-keymap))
-(define-key dungeon-mode-map "\r" 'dun-parse)
+(define-obsolete-variable-alias 'dungeon-mode-map 'dun-mode-map "22.1")
+(define-key dun-mode-map "\r" 'dun-parse)
 (defvar dungeon-batch-map (make-keymap))
 (if (string= (substring emacs-version 0 2) "18")
     (let (n)
@@ -2581,7 +2569,7 @@ treasures for points?" "4" "four")
     (insert ")")
     (setq eval-error nil)
     (condition-case nil
-       (eval-current-buffer)
+       (eval-buffer)
       (error (setq eval-error t)))
     (kill-buffer (current-buffer))
     (switch-to-buffer "*dungeon*")
@@ -2594,7 +2582,7 @@ treasures for points?" "4" "four")
   (if dun-logged-in
       (progn
        (setq dungeon-mode 'unix)
-       (define-key dungeon-mode-map "\r" 'dun-unix-parse)
+       (define-key dun-mode-map "\r" 'dun-unix-parse)
        (dun-mprinc "$ "))))
 
 (defun dun-login ()
@@ -2860,7 +2848,7 @@ drwxr-xr-x  3 root     staff          2048 Jan 1 1970 ..")
 (defun dun-uexit (args)
   (setq dungeon-mode 'dungeon)
   (dun-mprincl "\nYou step back from the console.")
-  (define-key dungeon-mode-map "\r" 'dun-parse)
+  (define-key dun-mode-map "\r" 'dun-parse)
   (if (not dun-batch-mode)
       (dun-messages)))
 
@@ -3059,7 +3047,7 @@ drwxr-xr-x  3 root     staff          2048 Jan 1 1970 ..")
 (defun dun-dos-interface ()
   (dun-dos-boot-msg)
   (setq dungeon-mode 'dos)
-  (define-key dungeon-mode-map "\r" 'dun-dos-parse)
+  (define-key dun-mode-map "\r" 'dun-dos-parse)
   (dun-dos-prompt))
 
 (defun dun-dos-type (args)
@@ -3117,7 +3105,7 @@ File not found")))
 (defun dun-dos-exit (args)
   (setq dungeon-mode 'dungeon)
   (dun-mprincl "\nYou power down the machine and step back.")
-  (define-key dungeon-mode-map "\r" 'dun-parse)
+  (define-key dun-mode-map "\r" 'dun-parse)
   (if (not dun-batch-mode)
       (dun-messages)))
 
@@ -3369,4 +3357,5 @@ File not found")))
 
 (provide 'dunnet)
 
+;; arch-tag: 4cc8e47c-d9e1-4ef4-936b-578e7f529558
 ;;; dunnet.el ends here