summaryrefslogtreecommitdiff
path: root/lisp/play
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/play')
-rw-r--r--lisp/play/5x5.el15
-rw-r--r--lisp/play/blackbox.el11
-rw-r--r--lisp/play/landmark.el19
-rw-r--r--lisp/play/mpuz.el12
-rw-r--r--lisp/play/snake.el16
5 files changed, 16 insertions, 57 deletions
diff --git a/lisp/play/5x5.el b/lisp/play/5x5.el
index 2e3f500766f..4bd0c4ddcf4 100644
--- a/lisp/play/5x5.el
+++ b/lisp/play/5x5.el
@@ -185,19 +185,8 @@ GRID is the grid of positions to click.")
;; Gameplay functions.
-(put '5x5-mode 'mode-class 'special)
-
-(defun 5x5-mode ()
- "A mode for playing `5x5'.
-
-The key bindings for `5x5-mode' are:
-
-\\{5x5-mode-map}"
- (kill-all-local-variables)
- (use-local-map 5x5-mode-map)
- (setq major-mode '5x5-mode
- mode-name "5x5")
- (run-mode-hooks '5x5-mode-hook)
+(define-derived-mode 5x5-mode special-mode "5x5"
+ "A mode for playing `5x5'."
(setq buffer-read-only t
truncate-lines t)
(buffer-disable-undo))
diff --git a/lisp/play/blackbox.el b/lisp/play/blackbox.el
index d38f799756b..ce2c928db0d 100644
--- a/lisp/play/blackbox.el
+++ b/lisp/play/blackbox.el
@@ -113,9 +113,8 @@
map))
;; Blackbox mode is suitable only for specially formatted data.
-(put 'blackbox-mode 'mode-class 'special)
-(defun blackbox-mode ()
+(define-derived-mode blackbox-mode special-mode "Blackbox"
"Major mode for playing blackbox.
To learn how to play blackbox, see the documentation for function `blackbox'.
@@ -124,13 +123,7 @@ The usual mnemonic keys move the cursor around the box.
\\[bb-romp] -- send in a ray from point, or toggle a ball at point
\\[bb-done] -- end game and get score"
- (interactive)
- (kill-all-local-variables)
- (use-local-map blackbox-mode-map)
- (setq truncate-lines t)
- (setq major-mode 'blackbox-mode)
- (setq mode-name "Blackbox")
- (run-mode-hooks 'blackbox-mode-hook))
+ (setq truncate-lines t))
;;;###autoload
(defun blackbox (num)
diff --git a/lisp/play/landmark.el b/lisp/play/landmark.el
index cf86d7a9de5..b995da4513c 100644
--- a/lisp/play/landmark.el
+++ b/lisp/play/landmark.el
@@ -233,10 +233,8 @@
(put 'landmark-mode 'intangible 1)
;; This one is for when they set view-read-only to t: Landmark cannot
;; allow View Mode to be activated in its buffer.
-(put 'landmark-mode 'mode-class 'special)
-
-(defun landmark-mode ()
- "Major mode for playing Landmark against Emacs.
+(define-derived-mode lm-mode special-mode "Lm"
+ "Major mode for playing Lm against Emacs.
You and Emacs play in turn by marking a free square. You mark it with X
and Emacs marks it with O. The winner is the first to get five contiguous
marks horizontally, vertically or in diagonal.
@@ -247,16 +245,9 @@ Other useful commands:
\\{landmark-mode-map}
Entry to this mode calls the value of `landmark-mode-hook' if that value
is non-nil. One interesting value is `turn-on-font-lock'."
- (interactive)
- (kill-all-local-variables)
- (setq major-mode 'landmark-mode
- mode-name "Landmark")
- (landmark-display-statistics)
- (use-local-map landmark-mode-map)
- (make-local-variable 'font-lock-defaults)
- (setq font-lock-defaults '(landmark-font-lock-keywords t)
- buffer-read-only t)
- (run-mode-hooks 'landmark-mode-hook))
+ (lm-display-statistics)
+ (setq-local font-lock-defaults '(lm-font-lock-keywords t))
+ (setq buffer-read-only t))
;;;_ + THE SCORE TABLE.
diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el
index e4e627a5293..f4c26bfc6c4 100644
--- a/lisp/play/mpuz.el
+++ b/lisp/play/mpuz.el
@@ -94,7 +94,9 @@ The value t means never ding, and `error' means only ding on wrong input."
map)
"Local keymap to use in Mult Puzzle.")
-(defun mpuz-mode ()
+
+
+(define-derived-mode mpuz-mode fundamental-mode "Mult Puzzle"
"Multiplication puzzle mode.
You have to guess which letters stand for which digits in the
@@ -106,13 +108,7 @@ then the digit. Thus, to guess that A=3, type `A 3'.
To leave the game to do other editing work, just switch buffers.
Then you may resume the game with M-x mpuz.
You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
- (interactive)
- (kill-all-local-variables)
- (setq major-mode 'mpuz-mode
- mode-name "Mult Puzzle"
- tab-width 30)
- (use-local-map mpuz-mode-map)
- (run-mode-hooks 'mpuz-mode-hook))
+ (setq tab-width 30))
;; Some variables for statistics
diff --git a/lisp/play/snake.el b/lisp/play/snake.el
index 85acfb116d2..4c110914298 100644
--- a/lisp/play/snake.el
+++ b/lisp/play/snake.el
@@ -353,21 +353,13 @@ Argument SNAKE-BUFFER is the name of the buffer."
(put 'snake-mode 'mode-class 'special)
-(defun snake-mode ()
- "A mode for playing Snake.
-
-Snake mode keybindings:
- \\{snake-mode-map}
-"
- (kill-all-local-variables)
+(define-derived-mode snake-mode special-mode "Snake"
+ "A mode for playing Snake."
(add-hook 'kill-buffer-hook 'gamegrid-kill-timer nil t)
(use-local-map snake-null-map)
- (setq major-mode 'snake-mode)
- (setq mode-name "Snake")
-
(unless (featurep 'emacs)
(setq mode-popup-menu
'("Snake Commands"
@@ -382,9 +374,7 @@ Snake mode keybindings:
(setq gamegrid-use-glyphs snake-use-glyphs-flag)
(setq gamegrid-use-color snake-use-color-flag)
- (gamegrid-init (snake-display-options))
-
- (run-mode-hooks 'snake-mode-hook))
+ (gamegrid-init (snake-display-options)))
;;;###autoload
(defun snake ()