summaryrefslogtreecommitdiff
path: root/lisp/play
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-09-10 23:31:56 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-09-10 23:31:56 -0400
commit1b3b87dfe0fae8e5266319531c0a874c8b4313b1 (patch)
tree167074a597924cfde441891481a9eb712b163422 /lisp/play
parent765da53c2084e3687201f06f8d050497f0e06da9 (diff)
downloademacs-1b3b87dfe0fae8e5266319531c0a874c8b4313b1.tar.gz
Use define-derived-mode (and derived-mode-p).
* lisp/play/snake.el (snake-mode): * lisp/play/mpuz.el (mpuz-mode): * lisp/play/landmark.el (lm-mode): * lisp/play/blackbox.el (blackbox-mode): * lisp/play/5x5.el (5x5-mode): * lisp/obsolete/options.el (Edit-options-mode): * lisp/net/quickurl.el (quickurl-list-mode): * lisp/net/newst-treeview.el (newsticker-treeview-mode): * lisp/mail/rmailsum.el (rmail-summary-mode): * lisp/mail/mspools.el (mspools-mode): * lisp/locate.el (locate-mode): * lisp/ibuffer.el (ibuffer-mode): * lisp/emulation/ws-mode.el (wordstar-mode): * lisp/emacs-lisp/debug.el (debugger-mode): * lisp/array.el (array-mode): * lisp/net/eudc.el (eudc-mode): Use define-derived-mode. * lisp/net/mairix.el (mairix-searches-mode-font-lock-keywords): Move initialization into declaration. (mairix-searches-mode): Use define-derived-mode. * lisp/net/eudc-hotlist.el (eudc-hotlist-mode): Use define-derived-mode. (eudc-edit-hotlist): Use dolist. * lisp/man.el (Man-mode-syntax-table): Rename from man-mode-syntax-table. (Man-mode): Use define-derived-mode. * lisp/info.el (Info-edit-mode-map): Rename from Info-edit-map. (Info-edit-mode): Use define-derived-mode. (Info-cease-edit): Use Info-mode. * lisp/eshell/esh-mode.el (eshell-mode-syntax-table): Move initialization into declaration. (eshell-mode): Use define-derived-mode. * lisp/chistory.el (command-history-mode-map): Rename from command-history-map. (command-history-mode): Use define-derived-mode. * lisp/calc/calc.el (calc-trail-mode-map): New var. (calc-trail-mode): Use define-derived-mode. (calc-trail-buffer): Set calc-main-buffer manually. * lisp/bookmark.el (bookmark-insert-annotation): New function. (bookmark-edit-annotation): Use it. (bookmark-edit-annotation-mode): Make it a proper major mode. (bookmark-send-edited-annotation): Use derived-mode-p. * lisp/arc-mode.el (archive-mode): Move kill-all-local-variables a tiny bit closer to its ideal place. Use \' to match EOS. * lisp/cedet/semantic/grammar.el (semantic-grammar-mode): Use define-derived-mode. (semantic-grammar-mode-syntax-table): Rename from semantic-grammar-syntax-table. (semantic-grammar-mode-map): Rename from semantic-grammar-map. * lisp/cedet/data-debug.el (data-debug-mode-map): Rename from data-debug-map. (data-debug-mode): Use define-derived-mode. * lisp/gnus/score-mode.el (gnus-score-mode-map): Move initialization into declaration. (gnus-score-mode): Use define-derived-mode. * lisp/gnus/gnus-srvr.el (gnus-browse-mode): Use define-derived-mode. * lisp/gnus/gnus-kill.el (gnus-kill-file-mode-map): Move initialization into declaration. (gnus-kill-file-mode): Use define-derived-mode. (gnus-kill-file-edit-file, gnus-kill-file-enter-kill, gnus-kill): Use derived-mode-p. * lisp/gnus/gnus-group.el (gnus-group-mode): Use define-derived-mode. (gnus-group-setup-buffer, gnus-group-name-at-point) (gnus-group-make-web-group, gnus-group-enter-directory) (gnus-group-suspend): Use derived-mode-p. * lisp/gnus/gnus-cus.el (gnus-custom-mode): Use define-derived-mode. * lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-mode): Use define-derived-mode. * lisp/gnus/gnus-art.el (gnus-article-mode): Use define-derived-mode. (gnus-article-setup-buffer, gnus-article-prepare) (gnus-article-prepare-display, gnus-sticky-article) (gnus-kill-sticky-article-buffer, gnus-kill-sticky-article-buffers) (gnus-bind-safe-url-regexp, gnus-article-check-buffer) (gnus-article-read-summary-keys): Use derived-mode-p.
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 ()