From: Stefan Kangas Date: Thu, 17 Oct 2019 16:49:33 +0000 (+0200) Subject: Port tetris menu to Emacs X-Git-Tag: emacs-27.0.90~1015 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dc0a218f62cab2eea245b1d577e1edc8e474364e;p=emacs.git Port tetris menu to Emacs * lisp/play/tetris.el (tetris--menu-def): New constant. (tetris-mode-menu, tetris-null-menu): Add a menu. (tetris-mode): Remove XEmacs compat code. (tetris-null-map, tetris-mode-map): Add docstring. --- diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el index a797a26d597..b5b77721ece 100644 --- a/lisp/play/tetris.el +++ b/lisp/play/tetris.el @@ -272,13 +272,40 @@ each one of its four blocks.") (define-key map [right] 'tetris-move-right) (define-key map [up] 'tetris-rotate-prev) (define-key map [down] 'tetris-move-down) - map)) + map) + "Keymap for Tetris games.") (defvar tetris-null-map (let ((map (make-sparse-keymap 'tetris-null-map))) (define-key map "n" 'tetris-start-game) (define-key map "q" 'quit-window) - map)) + map) + "Keymap for finished Tetris games.") + +(defconst tetris--menu-def + '("Tetris" + ["Start new game" tetris-start-game + :help "Start a new Tetris game"] + ["End game" tetris-end-game + :active (tetris-active-p) + :help "End the current Tetris game"] + ["Pause" tetris-pause-game + :active (and (tetris-active-p) (not tetris-paused)) + :help "Pause running Tetris game"] + ["Resume" tetris-pause-game + :active (and (tetris-active-p) tetris-paused) + :help "Resume paused Tetris game"]) + "Menu for `tetris'. Used to initialize menus.") + +(easy-menu-define + tetris-mode-menu tetris-mode-map + "Menu for running Tetris games." + tetris--menu-def) + +(easy-menu-define + tetris-null-menu tetris-null-map + "Menu for finished Tetris games." + tetris--menu-def) ;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -599,17 +626,6 @@ Drops the shape one square, testing for collision." (use-local-map tetris-null-map) - (unless (featurep 'emacs) - (setq mode-popup-menu - '("Tetris Commands" - ["Start new game" tetris-start-game] - ["End game" tetris-end-game - (tetris-active-p)] - ["Pause" tetris-pause-game - (and (tetris-active-p) (not tetris-paused))] - ["Resume" tetris-pause-game - (and (tetris-active-p) tetris-paused)]))) - (setq show-trailing-whitespace nil) (setq gamegrid-use-glyphs tetris-use-glyphs)