mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-16 17:19:41 +00:00
Simplify by using `define-derived-mode'.
* info.el (Info-mode): * calendar/todo-mode.el (todo-mode): * play/gomoku.el (gomoku-mode): Define with `define-derived-mode'. (gomoku-mode-map): Move initialization into declaration.
This commit is contained in:
parent
5f2b693f18
commit
528b9ea9ff
@ -1,3 +1,11 @@
|
||||
2010-04-15 Juanma Barranquero <lekktu@gmail.com>
|
||||
|
||||
Simplify by using `define-derived-mode'.
|
||||
* info.el (Info-mode):
|
||||
* calendar/todo-mode.el (todo-mode):
|
||||
* play/gomoku.el (gomoku-mode): Define with `define-derived-mode'.
|
||||
(gomoku-mode-map): Move initialization into declaration.
|
||||
|
||||
2010-04-14 Michael Albinus <michael.albinus@gmx.de>
|
||||
|
||||
Fix Bug#5840.
|
||||
|
@ -918,17 +918,9 @@ If INCLUDE-SEP is non-nil, return point after the separator."
|
||||
|
||||
;; As calendar reads .todo-do before todo-mode is loaded.
|
||||
;;;###autoload
|
||||
(defun todo-mode ()
|
||||
"Major mode for editing TODO lists.
|
||||
|
||||
\\{todo-mode-map}"
|
||||
(interactive)
|
||||
(kill-all-local-variables)
|
||||
(setq major-mode 'todo-mode)
|
||||
(setq mode-name "TODO")
|
||||
(use-local-map todo-mode-map)
|
||||
(easy-menu-add todo-menu)
|
||||
(run-mode-hooks 'todo-mode-hook))
|
||||
(define-derived-mode todo-mode nil "TODO"
|
||||
"Major mode for editing TODO lists."
|
||||
(easy-menu-add todo-menu))
|
||||
|
||||
(defvar date)
|
||||
(defvar entry)
|
||||
|
29
lisp/info.el
29
lisp/info.el
@ -3833,7 +3833,7 @@ With a zero prefix arg, put the name inside a function call to `info'."
|
||||
|
||||
;; Autoload cookie needed by desktop.el
|
||||
;;;###autoload
|
||||
(defun Info-mode ()
|
||||
(define-derived-mode Info-mode nil "Info"
|
||||
"Info mode provides commands for browsing through the Info documentation tree.
|
||||
Documentation in Info is divided into \"nodes\", each of which discusses
|
||||
one topic and contains references to other nodes which discuss related
|
||||
@ -3895,23 +3895,17 @@ Advanced commands:
|
||||
\\[clone-buffer] Select a new cloned Info buffer in another window.
|
||||
\\[universal-argument] \\[info] Move to new Info file with completion.
|
||||
\\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>."
|
||||
(kill-all-local-variables)
|
||||
(setq major-mode 'Info-mode)
|
||||
(setq mode-name "Info")
|
||||
:syntax-table text-mode-syntax-table
|
||||
:abbrev-table text-mode-abbrev-table
|
||||
(setq tab-width 8)
|
||||
(use-local-map Info-mode-map)
|
||||
(add-hook 'activate-menubar-hook 'Info-menu-update nil t)
|
||||
(set-syntax-table text-mode-syntax-table)
|
||||
(setq local-abbrev-table text-mode-abbrev-table)
|
||||
(setq case-fold-search t)
|
||||
(setq buffer-read-only t)
|
||||
(make-local-variable 'Info-current-file)
|
||||
(make-local-variable 'Info-current-subfile)
|
||||
(make-local-variable 'Info-current-node)
|
||||
(make-local-variable 'Info-tag-table-marker)
|
||||
(setq Info-tag-table-marker (make-marker))
|
||||
(make-local-variable 'Info-tag-table-buffer)
|
||||
(setq Info-tag-table-buffer nil)
|
||||
(set (make-local-variable 'Info-tag-table-marker) (make-marker))
|
||||
(set (make-local-variable 'Info-tag-table-buffer) nil)
|
||||
(make-local-variable 'Info-history)
|
||||
(make-local-variable 'Info-history-forward)
|
||||
(make-local-variable 'Info-index-alternatives)
|
||||
@ -3920,12 +3914,10 @@ Advanced commands:
|
||||
'(:eval (get-text-property (point-min) 'header-line))))
|
||||
(set (make-local-variable 'tool-bar-map) info-tool-bar-map)
|
||||
;; This is for the sake of the invisible text we use handling titles.
|
||||
(make-local-variable 'line-move-ignore-invisible)
|
||||
(setq line-move-ignore-invisible t)
|
||||
(make-local-variable 'desktop-save-buffer)
|
||||
(make-local-variable 'widen-automatically)
|
||||
(setq widen-automatically nil)
|
||||
(setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
|
||||
(set (make-local-variable 'line-move-ignore-invisible) t)
|
||||
(set (make-local-variable 'desktop-save-buffer)
|
||||
'Info-desktop-buffer-misc-data)
|
||||
(set (make-local-variable 'widen-automatically) nil)
|
||||
(add-hook 'kill-buffer-hook 'Info-kill-buffer nil t)
|
||||
(add-hook 'clone-buffer-hook 'Info-clone-buffer nil t)
|
||||
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
|
||||
@ -3944,8 +3936,7 @@ Advanced commands:
|
||||
'Info-revert-buffer-function)
|
||||
(Info-set-mode-line)
|
||||
(set (make-local-variable 'bookmark-make-record-function)
|
||||
'Info-bookmark-make-record)
|
||||
(run-mode-hooks 'Info-mode-hook))
|
||||
'Info-bookmark-make-record))
|
||||
|
||||
;; When an Info buffer is killed, make sure the associated tags buffer
|
||||
;; is killed too.
|
||||
|
@ -102,59 +102,60 @@ One useful value to include is `turn-on-font-lock' to highlight the pieces."
|
||||
"*Number of lines between the Gomoku board and the top of the window.")
|
||||
|
||||
|
||||
(defvar gomoku-mode-map nil
|
||||
(defvar gomoku-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
|
||||
;; Key bindings for cursor motion.
|
||||
(define-key map "y" 'gomoku-move-nw) ; y
|
||||
(define-key map "u" 'gomoku-move-ne) ; u
|
||||
(define-key map "b" 'gomoku-move-sw) ; b
|
||||
(define-key map "n" 'gomoku-move-se) ; n
|
||||
(define-key map "h" 'backward-char) ; h
|
||||
(define-key map "l" 'forward-char) ; l
|
||||
(define-key map "j" 'gomoku-move-down) ; j
|
||||
(define-key map "k" 'gomoku-move-up) ; k
|
||||
|
||||
(define-key map [kp-7] 'gomoku-move-nw)
|
||||
(define-key map [kp-9] 'gomoku-move-ne)
|
||||
(define-key map [kp-1] 'gomoku-move-sw)
|
||||
(define-key map [kp-3] 'gomoku-move-se)
|
||||
(define-key map [kp-4] 'backward-char)
|
||||
(define-key map [kp-6] 'forward-char)
|
||||
(define-key map [kp-2] 'gomoku-move-down)
|
||||
(define-key map [kp-8] 'gomoku-move-up)
|
||||
|
||||
(define-key map "\C-n" 'gomoku-move-down) ; C-n
|
||||
(define-key map "\C-p" 'gomoku-move-up) ; C-p
|
||||
|
||||
;; Key bindings for entering Human moves.
|
||||
(define-key map "X" 'gomoku-human-plays) ; X
|
||||
(define-key map "x" 'gomoku-human-plays) ; x
|
||||
(define-key map " " 'gomoku-human-plays) ; SPC
|
||||
(define-key map "\C-m" 'gomoku-human-plays) ; RET
|
||||
(define-key map "\C-c\C-p" 'gomoku-human-plays) ; C-c C-p
|
||||
(define-key map "\C-c\C-b" 'gomoku-human-takes-back) ; C-c C-b
|
||||
(define-key map "\C-c\C-r" 'gomoku-human-resigns) ; C-c C-r
|
||||
(define-key map "\C-c\C-e" 'gomoku-emacs-plays) ; C-c C-e
|
||||
|
||||
(define-key map [kp-enter] 'gomoku-human-plays)
|
||||
(define-key map [insert] 'gomoku-human-plays)
|
||||
(define-key map [down-mouse-1] 'gomoku-click)
|
||||
(define-key map [drag-mouse-1] 'gomoku-click)
|
||||
(define-key map [mouse-1] 'gomoku-click)
|
||||
(define-key map [down-mouse-2] 'gomoku-click)
|
||||
(define-key map [mouse-2] 'gomoku-mouse-play)
|
||||
(define-key map [drag-mouse-2] 'gomoku-mouse-play)
|
||||
|
||||
(define-key map [remap previous-line] 'gomoku-move-up)
|
||||
(define-key map [remap next-line] 'gomoku-move-down)
|
||||
(define-key map [remap move-beginning-of-line] 'gomoku-beginning-of-line)
|
||||
(define-key map [remap move-end-of-line] 'gomoku-end-of-line)
|
||||
(define-key map [remap undo] 'gomoku-human-takes-back)
|
||||
(define-key map [remap advertised-undo] 'gomoku-human-takes-back)
|
||||
map)
|
||||
|
||||
"Local keymap to use in Gomoku mode.")
|
||||
|
||||
(if gomoku-mode-map nil
|
||||
(setq gomoku-mode-map (make-sparse-keymap))
|
||||
|
||||
;; Key bindings for cursor motion.
|
||||
(define-key gomoku-mode-map "y" 'gomoku-move-nw) ; y
|
||||
(define-key gomoku-mode-map "u" 'gomoku-move-ne) ; u
|
||||
(define-key gomoku-mode-map "b" 'gomoku-move-sw) ; b
|
||||
(define-key gomoku-mode-map "n" 'gomoku-move-se) ; n
|
||||
(define-key gomoku-mode-map "h" 'backward-char) ; h
|
||||
(define-key gomoku-mode-map "l" 'forward-char) ; l
|
||||
(define-key gomoku-mode-map "j" 'gomoku-move-down) ; j
|
||||
(define-key gomoku-mode-map "k" 'gomoku-move-up) ; k
|
||||
|
||||
(define-key gomoku-mode-map [kp-7] 'gomoku-move-nw)
|
||||
(define-key gomoku-mode-map [kp-9] 'gomoku-move-ne)
|
||||
(define-key gomoku-mode-map [kp-1] 'gomoku-move-sw)
|
||||
(define-key gomoku-mode-map [kp-3] 'gomoku-move-se)
|
||||
(define-key gomoku-mode-map [kp-4] 'backward-char)
|
||||
(define-key gomoku-mode-map [kp-6] 'forward-char)
|
||||
(define-key gomoku-mode-map [kp-2] 'gomoku-move-down)
|
||||
(define-key gomoku-mode-map [kp-8] 'gomoku-move-up)
|
||||
|
||||
(define-key gomoku-mode-map "\C-n" 'gomoku-move-down) ; C-n
|
||||
(define-key gomoku-mode-map "\C-p" 'gomoku-move-up) ; C-p
|
||||
|
||||
;; Key bindings for entering Human moves.
|
||||
(define-key gomoku-mode-map "X" 'gomoku-human-plays) ; X
|
||||
(define-key gomoku-mode-map "x" 'gomoku-human-plays) ; x
|
||||
(define-key gomoku-mode-map " " 'gomoku-human-plays) ; SPC
|
||||
(define-key gomoku-mode-map "\C-m" 'gomoku-human-plays) ; RET
|
||||
(define-key gomoku-mode-map "\C-c\C-p" 'gomoku-human-plays) ; C-c C-p
|
||||
(define-key gomoku-mode-map "\C-c\C-b" 'gomoku-human-takes-back) ; C-c C-b
|
||||
(define-key gomoku-mode-map "\C-c\C-r" 'gomoku-human-resigns) ; C-c C-r
|
||||
(define-key gomoku-mode-map "\C-c\C-e" 'gomoku-emacs-plays) ; C-c C-e
|
||||
|
||||
(define-key gomoku-mode-map [kp-enter] 'gomoku-human-plays)
|
||||
(define-key gomoku-mode-map [insert] 'gomoku-human-plays)
|
||||
(define-key gomoku-mode-map [down-mouse-1] 'gomoku-click)
|
||||
(define-key gomoku-mode-map [drag-mouse-1] 'gomoku-click)
|
||||
(define-key gomoku-mode-map [mouse-1] 'gomoku-click)
|
||||
(define-key gomoku-mode-map [down-mouse-2] 'gomoku-click)
|
||||
(define-key gomoku-mode-map [mouse-2] 'gomoku-mouse-play)
|
||||
(define-key gomoku-mode-map [drag-mouse-2] 'gomoku-mouse-play)
|
||||
|
||||
(define-key gomoku-mode-map [remap previous-line] 'gomoku-move-up)
|
||||
(define-key gomoku-mode-map [remap next-line] 'gomoku-move-down)
|
||||
(define-key gomoku-mode-map [remap move-beginning-of-line] 'gomoku-beginning-of-line)
|
||||
(define-key gomoku-mode-map [remap move-end-of-line] 'gomoku-end-of-line)
|
||||
(define-key gomoku-mode-map [remap undo] 'gomoku-human-takes-back)
|
||||
(define-key gomoku-mode-map [remap advertised-undo] 'gomoku-human-takes-back))
|
||||
|
||||
(defvar gomoku-emacs-won ()
|
||||
"For making font-lock use the winner's face for the line.")
|
||||
@ -182,28 +183,20 @@ One useful value to include is `turn-on-font-lock' to highlight the pieces."
|
||||
;; allow View Mode to be activated in its buffer.
|
||||
(put 'gomoku-mode 'mode-class 'special)
|
||||
|
||||
(defun gomoku-mode ()
|
||||
(define-derived-mode gomoku-mode nil "Gomoku"
|
||||
"Major mode for playing Gomoku 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.
|
||||
|
||||
\\<gomoku-mode-map>
|
||||
You play by moving the cursor over the square you choose and hitting \\[gomoku-human-plays].
|
||||
|
||||
Other useful commands:
|
||||
\\{gomoku-mode-map}
|
||||
Entry to this mode calls the value of `gomoku-mode-hook' if that value
|
||||
is non-nil."
|
||||
(interactive)
|
||||
(kill-all-local-variables)
|
||||
(setq major-mode 'gomoku-mode
|
||||
mode-name "Gomoku")
|
||||
Other useful commands:\n
|
||||
\\{gomoku-mode-map}"
|
||||
(gomoku-display-statistics)
|
||||
(use-local-map gomoku-mode-map)
|
||||
(make-local-variable 'font-lock-defaults)
|
||||
(setq font-lock-defaults '(gomoku-font-lock-keywords t))
|
||||
(toggle-read-only t)
|
||||
(run-mode-hooks 'gomoku-mode-hook))
|
||||
(toggle-read-only t))
|
||||
|
||||
;;;
|
||||
;;; THE BOARD.
|
||||
|
Loading…
Reference in New Issue
Block a user