From 8ee205d232574e12921b052c7e93b7e16d6f1187 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 9 Mar 2023 16:19:16 -0500 Subject: [PATCH] gud.el: Bring back the pseudo-tool-bar in text frames (bug#62041) commit 8bb5c1bfec0929f2ba419e1c503f5acc01c336c2 accidentally threw away the pseudo-tool-bar implemented in the text frames' menu-bar of gud-minor-mode buffers. Bring it back, and while we're at it, improve it so it also works right when you have both text and GUI frames. Also fix a misunderstanding in last change (`gud-mode-map` does need to have a Gud menu, because `gud-mode` buffers already have it by virtue of being in `gud-minor-mode` as well). * lisp/progmodes/gud.el (gud-text-menu-bar-map): New keymap. (gud-menu-mode-map): Rename from `gud-shared-mode-map`. (gud-menu-map): Adjust accordingly. (gud-minor-mode-map): Use them. (gud-mode-map): Don't inherit from the shared/menu keymap. --- lisp/progmodes/gud.el | 56 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index cfe5f75d19f..42d64952d86 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -159,17 +159,61 @@ Used to gray out relevant toolbar icons.") (t (comint-interrupt-subjob))))) -(defvar-keymap gud-shared-mode-map +(defvar-keymap gud-text-menu-bar-map + :doc "Menu-bar keymap used in GUD buffers on text frames." + ;; Use the menu-bar as a pseudo-tool-bar. + "" `(,(propertize "down" 'face 'font-lock-doc-face) . gud-down) + "" `(,(propertize "up" 'face 'font-lock-doc-face) . gud-up) + "" `(,(propertize "finish" 'face 'font-lock-doc-face) . gud-finish) + "" `(,(propertize "step" 'face 'font-lock-doc-face) . gud-step) + "" `(,(propertize "next" 'face 'font-lock-doc-face) . gud-next) + "" `(menu-item + ,(propertize "until" 'face 'font-lock-doc-face) gud-until + :visible (memq gud-minor-mode '(gdbmi gdb perldb))) + "" `(menu-item + ,(propertize "cont" 'face 'font-lock-doc-face) gud-cont + :visible (not (eq gud-minor-mode 'gdbmi))) + "" `(menu-item + ,(propertize "run" 'face 'font-lock-doc-face) gud-run + :visible (memq gud-minor-mode '(gdbmi gdb dbx jdb))) + "" `(menu-bar-item + ,(propertize " go " 'face 'font-lock-doc-face) gud-go + :visible (and (eq gud-minor-mode 'gdbmi) + (gdb-show-run-p))) + "" `(menu-item + ,(propertize "stop" 'face 'font-lock-doc-face) gud-stop-subjob + :visible (or (and (eq gud-minor-mode 'gdbmi) + (gdb-show-stop-p)) + (not (eq gud-minor-mode 'gdbmi)))) + "" `(,(propertize "print" 'face 'font-lock-doc-face) . gud-print) + ;; Hide the usual menus to make room. + "" #'undefined + "" #'undefined + "" #'undefined + "" #'undefined + "" #'undefined) + +(defvar-keymap gud-menu-mode-map :doc "Keymap shared between `gud-mode' and `gud-minor-mode'.") (defvar-keymap gud-mode-map :doc "`gud-mode' keymap." - :parent (make-composed-keymap gud-shared-mode-map comint-mode-map)) + ;; BEWARE: `gud-mode-map' does not inherit from something like + ;; `gud-menu-mode-map' because the `gud-mode' buffer is also in + ;; `gud-minor-mode'. + ;;:parent (make-composed-keymap gud-menu-mode-map comint-mode-map) + ) (defvar-keymap gud-minor-mode-map - :parent gud-shared-mode-map) - -(easy-menu-define gud-menu-map gud-shared-mode-map + ;; Part of the menu is dynamic, so we use 2 keymaps: `gud-menu-mode-map' + ;; is the static/normal menu defined with easy-menu, and + ;; `gud-text-menu-bar-map' is the part that's only used on text frames. + ;; We then merge them here into `gud-minor-mode-map'. + :parent gud-menu-mode-map + "" `(menu-item nil ,gud-text-menu-bar-map + :filter ,(lambda (map) (unless window-system map)))) + +(easy-menu-define gud-menu-map gud-menu-mode-map "Menu for `gud-mode'." '("Gud" ["Continue" gud-cont @@ -279,7 +323,7 @@ Used to gray out relevant toolbar icons.") (gud-goto-info . "info")) map) (tool-bar-local-item-from-menu - (car x) (cdr x) map gud-minor-mode-map)))) + (car x) (cdr x) map gud-menu-mode-map)))) (defvar gud-gdb-repeat-map (let ((map (make-sparse-keymap))) -- 2.39.2