From: Stefan Kangas Date: Thu, 17 Oct 2019 17:38:06 +0000 (+0200) Subject: Port snake menu to Emacs X-Git-Tag: emacs-27.0.90~1011 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0a70727c4024ac6a66c378df52e37808ee2d7993;p=emacs.git Port snake menu to Emacs * lisp/play/snake.el (snake--menu-def): New constant. (snake-mode-menu, snake-null-menu): Add a menu. (snake-mode): Remove XEmacs compat code. (snake-mode-map, snake-null-map): Add docstring. --- diff --git a/lisp/play/snake.el b/lisp/play/snake.el index d0f94579062..5e8a718f5a1 100644 --- a/lisp/play/snake.el +++ b/lisp/play/snake.el @@ -186,12 +186,39 @@ and then start moving it leftwards.") (define-key map "\C-f" 'snake-move-right) (define-key map "\C-p" 'snake-move-up) (define-key map "\C-n" 'snake-move-down) - map)) + map) + "Keymap for Snake games.") (defvar snake-null-map (let ((map (make-sparse-keymap 'snake-null-map))) (define-key map "n" 'snake-start-game) - map)) + map) + "Keymap for finished Snake games.") + +(defconst snake--menu-def + '("Snake" + ["Start new game" snake-start-game + :help "Start a new Snake game"] + ["End game" snake-end-game + :active (snake-active-p) + :help "End the current Snake game"] + ["Pause" snake-pause-game + :active (and (snake-active-p) (not snake-paused)) + :help "Pause running Snake game"] + ["Resume" snake-pause-game + :active (and (snake-active-p) snake-paused) + :help "Resume paused Snake game"]) + "Menu for `snake'. Used to initialize menus.") + +(easy-menu-define + snake-mode-menu snake-mode-map + "Menu for running Snake games." + snake--menu-def) + +(easy-menu-define + snake-null-menu snake-null-map + "Menu for finished Snake games." + snake--menu-def) ;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -368,17 +395,6 @@ Argument SNAKE-BUFFER is the name of the buffer." (use-local-map snake-null-map) - (unless (featurep 'emacs) - (setq mode-popup-menu - '("Snake Commands" - ["Start new game" snake-start-game] - ["End game" snake-end-game - (snake-active-p)] - ["Pause" snake-pause-game - (and (snake-active-p) (not snake-paused))] - ["Resume" snake-pause-game - (and (snake-active-p) snake-paused)]))) - (setq gamegrid-use-glyphs snake-use-glyphs-flag) (setq gamegrid-use-color snake-use-color-flag)