]> git.eshelyaron.com Git - emacs.git/commitdiff
Use defvar-keymap in play/*.el
authorStefan Kangas <stefan@marxist.se>
Fri, 31 Dec 2021 16:17:16 +0000 (17:17 +0100)
committerStefan Kangas <stefan@marxist.se>
Fri, 31 Dec 2021 16:17:16 +0000 (17:17 +0100)
* lisp/play/5x5.el (5x5-mode-map):
* lisp/play/blackbox.el (blackbox-mode-map):
* lisp/play/bubbles.el (bubbles-mode-map):
* lisp/play/decipher.el (decipher-mode-map):
* lisp/play/doctor.el (doctor-mode-map):
* lisp/play/gametree.el (gametree-mode-map):
* lisp/play/gomoku.el (gomoku-mode-map):
* lisp/play/mpuz.el (mpuz-mode-map):
* lisp/play/pong.el (pong-mode-map):
* lisp/play/solitaire.el (solitaire-mode-map): Use defvar-keymap.

lisp/play/5x5.el
lisp/play/blackbox.el
lisp/play/bubbles.el
lisp/play/decipher.el
lisp/play/doctor.el
lisp/play/gametree.el
lisp/play/gomoku.el
lisp/play/mpuz.el
lisp/play/pong.el
lisp/play/solitaire.el

index 085c97f5d8e1de5b6baa8089fc392a9b060d977a..155c08f0adea60c7ac1484f34d99eefda0716e74 100644 (file)
 (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.
index 1b82d1a4259ecc4f84c649c295624af237faae01..d937550208975a7becab22ced2562095f581f526 100644 (file)
 (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.
 
index e695a75e083540c4b5657a55fbc7ad966171064d..471dea8d5805004948f04c90467487fd1d35a47b 100644 (file)
@@ -809,22 +809,21 @@ static char * dot3d_xpm[] = {
   (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'."
index 5431d7f068a88c6a4d151b90427dafae75aeb190..613f254fd2db1e7dd591a3ea06732b2615b2b994 100644 (file)
@@ -138,36 +138,31 @@ the tail of the list."
      (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
index 33fecaa188aca4acd584d8379efaf1872bba786c..e45619d1c79d76213ecf4c8b3e957777c207c066 100644 (file)
     (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.
index ff4b97d884c4a6fb790b592f952f2f13c716b6e5..b7ebe3dcd3ac3b1e23980a19319191946f9f49a8 100644 (file)
@@ -580,26 +580,20 @@ buffer, it is replaced by the new value.  See the documentation for
 \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.
index 0a45885b875b11af188b4b064a6c94cc78a92c8a..97726fcad76ee153da52fe6327800aaf3b233100 100644 (file)
@@ -100,65 +100,61 @@ SHOULD be at least 2 (MUST BE at least 1).")
   "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 ()
index df2b6fc867a0bee652a2a44cfb08f81a52e055f5..6091016b7c3b58f3990d6af4a8c4129c2fd26996 100644 (file)
@@ -76,17 +76,12 @@ The value t means never ding, and `error' means only ding on wrong input."
   "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
index b8545dfa82f913a856683ba7f14621e4fe16375a..f1426d8f0fa3f14f59b9006ce65419651bf51094 100644 (file)
 
 ;;; 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)
 
 
 
index bc1a0e44cbf78f99ff660038f5466021379fe23d..19d7ba51bc27e7df6225e2fd38ae7563d53af16a 100644 (file)
   "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)