(defvar 5x5-buffer-name "*5x5*"
"Name of the 5x5 play buffer.")
-(defvar 5x5-mode-map
- (let ((map (make-sparse-keymap)))
- (suppress-keymap map t)
- (define-key map "?" #'describe-mode)
- (define-key map "\r" #'5x5-flip-current)
- (define-key map " " #'5x5-flip-current)
- (define-key map [up] #'5x5-up)
- (define-key map [down] #'5x5-down)
- (define-key map [left] #'5x5-left)
- (define-key map [tab] #'5x5-right)
- (define-key map [right] #'5x5-right)
- (define-key map [(control a)] #'5x5-bol)
- (define-key map [(control e)] #'5x5-eol)
- (define-key map [(control p)] #'5x5-up)
- (define-key map [(control n)] #'5x5-down)
- (define-key map [(control b)] #'5x5-left)
- (define-key map [(control f)] #'5x5-right)
- (define-key map [home] #'5x5-bol)
- (define-key map [end] #'5x5-eol)
- (define-key map [prior] #'5x5-first)
- (define-key map [next] #'5x5-last)
- (define-key map "r" #'5x5-randomize)
- (define-key map [(control c) (control r)] #'5x5-crack-randomly)
- (define-key map [(control c) (control c)] #'5x5-crack-mutating-current)
- (define-key map [(control c) (control b)] #'5x5-crack-mutating-best)
- (define-key map [(control c) (control x)] #'5x5-crack-xor-mutate)
- (define-key map "n" #'5x5-new-game)
- (define-key map "s" #'5x5-solve-suggest)
- (define-key map "<" #'5x5-solve-rotate-left)
- (define-key map ">" #'5x5-solve-rotate-right)
- (define-key map "q" #'5x5-quit-game)
- map)
- "Local keymap for the 5x5 game.")
+(defvar-keymap 5x5-mode-map
+ :doc "Local keymap for the 5x5 game."
+ :suppress 'nodigits
+ "?" #'describe-mode
+ "RET" #'5x5-flip-current
+ "SPC" #'5x5-flip-current
+ "<up>" #'5x5-up
+ "<down>" #'5x5-down
+ "<left>" #'5x5-left
+ "<tab>" #'5x5-right
+ "<right>" #'5x5-right
+ "C-a" #'5x5-bol
+ "C-e" #'5x5-eol
+ "C-p" #'5x5-up
+ "C-n" #'5x5-down
+ "C-b" #'5x5-left
+ "C-f" #'5x5-right
+ "<home>" #'5x5-bol
+ "<end>" #'5x5-eol
+ "<prior>" #'5x5-first
+ "<next>" #'5x5-last
+ "r" #'5x5-randomize
+ "C-c C-r" #'5x5-crack-randomly
+ "C-c C-c" #'5x5-crack-mutating-current
+ "C-c C-b" #'5x5-crack-mutating-best
+ "C-c C-x" #'5x5-crack-xor-mutate
+ "n" #'5x5-new-game
+ "s" #'5x5-solve-suggest
+ "<" #'5x5-solve-rotate-left
+ ">" #'5x5-solve-rotate-right
+ "q" #'5x5-quit-game)
(defvar-local 5x5-solver-output nil
"List that is the output of an arithmetic solver.
(defvar bb-balls-placed nil
"List of already placed balls.")
-(defvar blackbox-mode-map
- (let ((map (make-sparse-keymap)))
- (suppress-keymap map t)
- (define-key map " " 'bb-romp)
- (define-key map "q" 'bury-buffer)
- (define-key map [insert] 'bb-romp)
- (define-key map [return] 'bb-done)
- (define-key map [remap backward-char] #'bb-left)
- (define-key map [remap left-char] #'bb-left)
- (define-key map [remap forward-char] #'bb-right)
- (define-key map [remap right-char] #'bb-right)
- (define-key map [remap previous-line] #'bb-up)
- (define-key map [remap next-line] #'bb-down)
- (define-key map [remap move-end-of-line] #'bb-eol)
- (define-key map [remap move-beginning-of-line] #'bb-bol)
- (define-key map [remap newline] #'bb-done)
- map))
+(defvar-keymap blackbox-mode-map
+ :suppress 'nodigits
+ "SPC" #'bb-romp
+ "q" #'bury-buffer
+ "<insert>" #'bb-romp
+ "<return>" #'bb-done
+ "<remap> <backward-char>" #'bb-left
+ "<remap> <left-char>" #'bb-left
+ "<remap> <forward-char>" #'bb-right
+ "<remap> <right-char>" #'bb-right
+ "<remap> <previous-line>" #'bb-up
+ "<remap> <next-line>" #'bb-down
+ "<remap> <move-end-of-line>" #'bb-eol
+ "<remap> <move-beginning-of-line>" #'bb-bol
+ "<remap> <newline>" #'bb-done)
;; Blackbox mode is suitable only for specially formatted data.
(bubbles--update-faces-or-images))
-(defvar bubbles-mode-map
- (let ((map (make-sparse-keymap 'bubbles-mode-map)))
- ;; (suppress-keymap map t)
- (define-key map "q" 'bubbles-quit)
- (define-key map "\n" 'bubbles-plop)
- (define-key map " " 'bubbles-plop)
- (define-key map [double-down-mouse-1] 'bubbles-plop)
- (define-key map [mouse-2] 'bubbles-plop)
- (define-key map "\C-m" 'bubbles-plop)
- (define-key map "u" 'bubbles-undo)
- (define-key map "p" 'previous-line)
- (define-key map "n" 'next-line)
- (define-key map "f" 'forward-char)
- (define-key map "b" 'backward-char)
- map)
- "Mode map for `bubbles'.")
+(defvar-keymap bubbles-mode-map
+ :doc "Mode map for `bubbles'."
+ :name 'bubbles-mode-map
+ "q" #'bubbles-quit
+ "C-j" #'bubbles-plop
+ "SPC" #'bubbles-plop
+ "C-m" #'bubbles-plop
+ "u" #'bubbles-undo
+ "p" #'previous-line
+ "n" #'next-line
+ "f" #'forward-char
+ "b" #'backward-char
+
+ "<double-down-mouse-1>" #'bubbles-plop
+ "<mouse-2>" #'bubbles-plop)
(easy-menu-define bubbles-menu bubbles-mode-map
"Menu for `bubbles'."
(2 font-lock-string-face)))
"Font Lock keywords for Decipher mode.")
-(defvar decipher-mode-map
- (let ((map (make-keymap)))
- (suppress-keymap map)
- (define-key map "A" #'decipher-show-alphabet)
- (define-key map "C" #'decipher-complete-alphabet)
- (define-key map "D" #'decipher-digram-list)
- (define-key map "F" #'decipher-frequency-count)
- (define-key map "M" #'decipher-make-checkpoint)
- (define-key map "N" #'decipher-adjacency-list)
- (define-key map "R" #'decipher-restore-checkpoint)
- (define-key map "U" #'decipher-undo)
- (define-key map " " #'decipher-keypress)
- (define-key map [remap undo] #'decipher-undo)
- (define-key map [remap advertised-undo] #'decipher-undo)
- (let ((key ?a))
- (while (<= key ?z)
- (define-key map (vector key) #'decipher-keypress)
- (cl-incf key)))
- map)
- "Keymap for Decipher mode.")
-
-
-(defvar decipher-stats-mode-map
- (let ((map (make-keymap)))
- (suppress-keymap map)
- (define-key map "D" #'decipher-digram-list)
- (define-key map "F" #'decipher-frequency-count)
- (define-key map "N" #'decipher-adjacency-list)
- map)
- "Keymap for Decipher-Stats mode.")
+(defvar-keymap decipher-mode-map
+ :doc "Keymap for Decipher mode."
+ :suppress t
+ "A" #'decipher-show-alphabet
+ "C" #'decipher-complete-alphabet
+ "D" #'decipher-digram-list
+ "F" #'decipher-frequency-count
+ "M" #'decipher-make-checkpoint
+ "N" #'decipher-adjacency-list
+ "R" #'decipher-restore-checkpoint
+ "U" #'decipher-undo
+ "SPC" #'decipher-keypress
+ "<remap> <undo>" #'decipher-undo
+ "<remap> <advertised-undo>" #'decipher-undo)
+(let ((key ?a))
+ (while (<= key ?z)
+ (keymap-set decipher-mode-map (char-to-string key) #'decipher-keypress)
+ (cl-incf key)))
+
+(defvar-keymap decipher-stats-mode-map
+ :doc "Keymap for Decipher-Stats mode."
+ :suppress t
+ "D" #'decipher-digram-list
+ "F" #'decipher-frequency-count
+ "N" #'decipher-adjacency-list)
(defvar decipher-mode-syntax-table
(set what ww)
first))
\f
-(defvar doctor-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map "\n" 'doctor-read-print)
- (define-key map "\r" 'doctor-ret-or-read)
- map))
+(defvar-keymap doctor-mode-map
+ "C-j" #'doctor-read-print
+ "RET" #'doctor-ret-or-read)
(define-derived-mode doctor-mode text-mode "Doctor"
"Major mode for running the Doctor (Eliza) program.
\f
;;;; Key bindings
-(defvar gametree-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map "\C-c\C-j" 'gametree-break-line-here)
- (define-key map "\C-c\C-v" 'gametree-insert-new-leaf)
- (define-key map "\C-c\C-m" 'gametree-merge-line)
- (define-key map "\C-c\C-r " 'gametree-layout-to-register)
- (define-key map "\C-c\C-r/" 'gametree-layout-to-register)
- (define-key map "\C-c\C-rj" 'gametree-apply-register-layout)
- (define-key map "\C-c\C-y" 'gametree-save-and-hack-layout)
- (define-key map "\C-c;" 'gametree-insert-score)
- (define-key map "\C-c^" 'gametree-compute-and-insert-score)
- (define-key map [M-down-mouse-2 M-mouse-2]
- #'gametree-mouse-break-line-here)
- (define-key map [S-down-mouse-1 S-mouse-1]
- #'gametree-mouse-show-children-and-entry)
- (define-key map [S-down-mouse-2 S-mouse-2]
- #'gametree-mouse-show-subtree)
- (define-key map [S-down-mouse-3 S-mouse-3]
- #'gametree-mouse-hide-subtree)
- map))
+(defvar-keymap gametree-mode-map
+ "C-c C-j" #'gametree-break-line-here
+ "C-c C-v" #'gametree-insert-new-leaf
+ "C-c C-m" #'gametree-merge-line
+ "C-c C-r SPC" #'gametree-layout-to-register
+ "C-c C-r /" #'gametree-layout-to-register
+ "C-c C-r j" #'gametree-apply-register-layout
+ "C-c C-y" #'gametree-save-and-hack-layout
+ "C-c ;" #'gametree-insert-score
+ "C-c ^" #'gametree-compute-and-insert-score
+ "M-<down-mouse-2> M-<mouse-2>" #'gametree-mouse-break-line-here
+ "S-<down-mouse-1> S-<mouse-1>" #'gametree-mouse-show-children-and-entry
+ "S-<down-mouse-2> S-<mouse-2>" #'gametree-mouse-show-subtree
+ "S-<down-mouse-3> S-<mouse-3>" #'gametree-mouse-hide-subtree)
(define-derived-mode gametree-mode outline-mode "GameTree"
"Major mode for managing game analysis trees.
"Number of lines between the Gomoku board and the top of the window.")
-(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" 'gomoku-move-left) ; h
- (define-key map "l" 'gomoku-move-right) ; 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] 'gomoku-move-left)
- (define-key map [kp-6] 'gomoku-move-right)
- (define-key map [kp-2] 'gomoku-move-down)
- (define-key map [kp-8] 'gomoku-move-up)
-
- (define-key map "\C-b" 'gomoku-move-left) ; C-b
- (define-key map "\C-f" 'gomoku-move-right) ; C-f
- (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 backward-char] 'gomoku-move-left)
- (define-key map [remap left-char] 'gomoku-move-left)
- (define-key map [remap forward-char] 'gomoku-move-right)
- (define-key map [remap right-char] 'gomoku-move-right)
- (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.")
+(defvar-keymap gomoku-mode-map
+ :doc "Local keymap to use in Gomoku mode."
+ ;; Key bindings for cursor motion.
+ "y" #'gomoku-move-nw
+ "u" #'gomoku-move-ne
+ "b" #'gomoku-move-sw
+ "n" #'gomoku-move-se
+ "h" #'gomoku-move-left
+ "l" #'gomoku-move-right
+ "j" #'gomoku-move-down
+ "k" #'gomoku-move-up
+
+ "<kp-7>" #'gomoku-move-nw
+ "<kp-9>" #'gomoku-move-ne
+ "<kp-1>" #'gomoku-move-sw
+ "<kp-3>" #'gomoku-move-se
+ "<kp-4>" #'gomoku-move-left
+ "<kp-6>" #'gomoku-move-right
+ "<kp-2>" #'gomoku-move-down
+ "<kp-8>" #'gomoku-move-up
+
+ "C-b" #'gomoku-move-left
+ "C-f" #'gomoku-move-right
+ "C-n" #'gomoku-move-down
+ "C-p" #'gomoku-move-up
+
+ ;; Key bindings for entering Human moves.
+ "X" #'gomoku-human-plays
+ "x" #'gomoku-human-plays
+ "SPC" #'gomoku-human-plays
+ "RET" #'gomoku-human-plays
+ "C-c C-p" #'gomoku-human-plays
+ "C-c C-b" #'gomoku-human-takes-back
+ "C-c C-r" #'gomoku-human-resigns
+ "C-c C-e" #'gomoku-emacs-plays
+
+ "<kp-enter>" #'gomoku-human-plays
+ "<insert>" #'gomoku-human-plays
+ "<down-mouse-1>" #'gomoku-click
+ "<drag-mouse-1>" #'gomoku-click
+ "<mouse-1>" #'gomoku-click
+ "<down-mouse-2>" #'gomoku-click
+ "<mouse-2>" #'gomoku-mouse-play
+ "<drag-mouse-2>" #'gomoku-mouse-play
+
+ "<remap> <backward-char>" #'gomoku-move-left
+ "<remap> <left-char>" #'gomoku-move-left
+ "<remap> <forward-char>" #'gomoku-move-right
+ "<remap> <right-char>" #'gomoku-move-right
+ "<remap> <previous-line>" #'gomoku-move-up
+ "<remap> <next-line>" #'gomoku-move-down
+ "<remap> <move-beginning-of-line>" #'gomoku-beginning-of-line
+ "<remap> <move-end-of-line>" #'gomoku-end-of-line
+ "<remap> <undo>" #'gomoku-human-takes-back
+ "<remap> <advertised-undo>" #'gomoku-human-takes-back)
(defvar gomoku-emacs-won ()
"Hook to run upon entry to mpuz."
:type 'hook)
-(defvar mpuz-mode-map
- (let ((map (make-sparse-keymap)))
- (mapc (lambda (ch)
- (define-key map (char-to-string ch) 'mpuz-try-letter))
- "abcdefghijABCDEFGHIJ")
- (define-key map "\C-g" 'mpuz-offer-abort)
- (define-key map "?" 'describe-mode)
- map)
- "Local keymap to use in Mult Puzzle.")
-
-
+(defvar-keymap mpuz-mode-map
+ :doc "Local keymap to use in Mult Puzzle."
+ "C-g" #'mpuz-offer-abort
+ "?" #'describe-mode)
+(dolist (ch (mapcar #'char-to-string "abcdefghijABCDEFGHIJ"))
+ (keymap-set mpuz-mode-map ch #'mpuz-try-letter))
(define-derived-mode mpuz-mode fundamental-mode "Mult Puzzle"
:interactive nil
;;; Initialize maps
-(defvar pong-mode-map
- (let ((map (make-sparse-keymap 'pong-mode-map)))
- (define-key map [left] 'pong-move-left)
- (define-key map [right] 'pong-move-right)
- (define-key map [up] 'pong-move-up)
- (define-key map [down] 'pong-move-down)
- (define-key map pong-left-key 'pong-move-left)
- (define-key map pong-right-key 'pong-move-right)
- (define-key map pong-up-key 'pong-move-up)
- (define-key map pong-down-key 'pong-move-down)
- (define-key map pong-quit-key 'pong-quit)
- (define-key map pong-pause-key 'pong-pause)
- map)
- "Modemap for pong-mode.")
-
-(defvar pong-null-map
- (make-sparse-keymap 'pong-null-map) "Null map for pong-mode.")
+(defvar-keymap pong-mode-map
+ :doc "Modemap for pong-mode."
+ :name 'pong-mode-map
+ "<left>" #'pong-move-left
+ "<right>" #'pong-move-right
+ "<up>" #'pong-move-up
+ "<down>" #'pong-move-down
+ pong-left-key #'pong-move-left
+ pong-right-key #'pong-move-right
+ pong-up-key #'pong-move-up
+ pong-down-key #'pong-move-down
+ pong-quit-key #'pong-quit
+ pong-pause-key #'pong-pause)
+
+(defvar-keymap pong-null-map
+ :doc "Null map for pong-mode."
+ :name 'pong-null-map)
"Hook to run upon entry to Solitaire."
:type 'hook)
-(defvar solitaire-mode-map
- (let ((map (make-sparse-keymap)))
- (set-keymap-parent map special-mode-map)
-
- (define-key map "\C-f" 'solitaire-right)
- (define-key map "\C-b" 'solitaire-left)
- (define-key map "\C-p" 'solitaire-up)
- (define-key map "\C-n" 'solitaire-down)
- (define-key map "\r" 'solitaire-move)
- (define-key map [remap undo] 'solitaire-undo)
- (define-key map " " 'solitaire-do-check)
-
- (define-key map [right] 'solitaire-right)
- (define-key map [left] 'solitaire-left)
- (define-key map [up] 'solitaire-up)
- (define-key map [down] 'solitaire-down)
-
- (define-key map [S-right] 'solitaire-move-right)
- (define-key map [S-left] 'solitaire-move-left)
- (define-key map [S-up] 'solitaire-move-up)
- (define-key map [S-down] 'solitaire-move-down)
-
- (define-key map [kp-6] 'solitaire-right)
- (define-key map [kp-4] 'solitaire-left)
- (define-key map [kp-8] 'solitaire-up)
- (define-key map [kp-2] 'solitaire-down)
- (define-key map [kp-5] 'solitaire-center-point)
-
- (define-key map [S-kp-6] 'solitaire-move-right)
- (define-key map [S-kp-4] 'solitaire-move-left)
- (define-key map [S-kp-8] 'solitaire-move-up)
- (define-key map [S-kp-2] 'solitaire-move-down)
-
- (define-key map [kp-enter] 'solitaire-move)
- (define-key map [kp-0] 'solitaire-undo)
-
- ;; spoil it with s ;)
- (define-key map [?s] 'solitaire-solve)
-
- ;; (define-key map [kp-0] 'solitaire-hint) - Not yet provided ;)
- map)
- "Keymap for playing Solitaire.")
+(defvar-keymap solitaire-mode-map
+ :doc "Keymap for playing Solitaire."
+ :parent special-mode-map
+ "C-f" #'solitaire-right
+ "C-b" #'solitaire-left
+ "C-p" #'solitaire-up
+ "C-n" #'solitaire-down
+ "RET" #'solitaire-move
+ "SPC" #'solitaire-do-check
+
+ "<right>" #'solitaire-right
+ "<left>" #'solitaire-left
+ "<up>" #'solitaire-up
+ "<down>" #'solitaire-down
+
+ "S-<right>" #'solitaire-move-right
+ "S-<left>" #'solitaire-move-left
+ "S-<up>" #'solitaire-move-up
+ "S-<down>" #'solitaire-move-down
+
+ "<kp-6>" #'solitaire-right
+ "<kp-4>" #'solitaire-left
+ "<kp-8>" #'solitaire-up
+ "<kp-2>" #'solitaire-down
+ "<kp-5>" #'solitaire-center-point
+
+ "S-<kp-6>" #'solitaire-move-right
+ "S-<kp-4>" #'solitaire-move-left
+ "S-<kp-8>" #'solitaire-move-up
+ "S-<kp-2>" #'solitaire-move-down
+
+ "<kp-enter>" #'solitaire-move
+ "<kp-0>" #'solitaire-undo
+ "<remap> <undo>" #'solitaire-undo
+
+ ;; spoil it with s ;)
+ "s" #'solitaire-solve
+
+ ;; "[kp-0]" #'solitaire-hint - Not yet provided ;)
+ )
;; Solitaire mode is suitable only for specially formatted data.
(put 'solitaire-mode 'mode-class 'special)