Revert "Make easy-mmode-defmap obsolete and adjust only caller"

This reverts commit 8bb5c1bfec.
That commit lost too many useful features in the GUD menus
and caused several bugs, the last of them bug#59769.

Do not merge to master.
This commit is contained in:
Eli Zaretskii 2022-12-03 11:16:41 +02:00
parent 17d40c163e
commit 3623d5c195
2 changed files with 139 additions and 90 deletions

View file

@ -725,7 +725,9 @@ The M, BS, and ARGS arguments are as per that function. DOC is
the constant's documentation. the constant's documentation.
This macro is deprecated; use `defvar-keymap' instead." This macro is deprecated; use `defvar-keymap' instead."
(declare (doc-string 3) (indent 1) (obsolete defvar-keymap "29.1")) ;; FIXME: Declare obsolete in favor of `defvar-keymap'. It is still
;; used for `gud-menu-map' and `gud-minor-mode-map', so fix that first.
(declare (doc-string 3) (indent 1))
`(defconst ,m `(defconst ,m
(easy-mmode-define-keymap ,bs nil (if (boundp ',m) ,m) ,(cons 'list args)) (easy-mmode-define-keymap ,bs nil (if (boundp ',m) ,m) ,(cons 'list args))
,doc)) ,doc))

View file

@ -159,96 +159,143 @@ Used to gray out relevant toolbar icons.")
(t (t
(comint-interrupt-subjob))))) (comint-interrupt-subjob)))))
(defvar-keymap gud-mode-map (easy-mmode-defmap gud-menu-map
;; Will inherit from comint-mode via define-derived-mode. '(([help] "Info (debugger)" . gud-goto-info)
:doc "`gud-mode' keymap.") ([tooltips] menu-item "Show GUD tooltips" gud-tooltip-mode
:enable (and (not emacs-basic-display)
(defvar-keymap gud-minor-mode-map (display-graphic-p)
:parent gud-mode-map) (fboundp 'x-show-tip))
:visible (memq gud-minor-mode
(easy-menu-define gud-menu-map gud-mode-map '(gdbmi guiler dbx sdb xdb pdb))
:button (:toggle . gud-tooltip-mode))
([refresh] "Refresh" . gud-refresh)
([run] menu-item "Run" gud-run
:enable (not gud-running)
:visible (or (memq gud-minor-mode '(gdb dbx jdb))
(and (eq gud-minor-mode 'gdbmi)
(or (not (gdb-show-run-p))
(bound-and-true-p
gdb-active-process)))))
([go] . (menu-item (if (bound-and-true-p gdb-active-process)
"Continue" "Run")
gud-go
:visible (and (eq gud-minor-mode 'gdbmi)
(gdb-show-run-p))))
([stop] menu-item "Stop" gud-stop-subjob
:visible (or (not (memq gud-minor-mode '(gdbmi pdb)))
(and (eq gud-minor-mode 'gdbmi)
(gdb-show-stop-p))))
([until] menu-item "Continue to selection" gud-until
:enable (not gud-running)
:visible (and (memq gud-minor-mode '(gdbmi gdb perldb))
(gud-tool-bar-item-visible-no-fringe)))
([remove] menu-item "Remove Breakpoint" gud-remove
:enable (not gud-running)
:visible (gud-tool-bar-item-visible-no-fringe))
([tbreak] menu-item "Temporary Breakpoint" gud-tbreak
:enable (not gud-running)
:visible (memq gud-minor-mode
'(gdbmi gdb sdb xdb)))
([break] menu-item "Set Breakpoint" gud-break
:enable (not gud-running)
:visible (gud-tool-bar-item-visible-no-fringe))
([up] menu-item "Up Stack" gud-up
:enable (not gud-running)
:visible (memq gud-minor-mode
'(gdbmi gdb guiler dbx xdb jdb pdb)))
([down] menu-item "Down Stack" gud-down
:enable (not gud-running)
:visible (memq gud-minor-mode
'(gdbmi gdb guiler dbx xdb jdb pdb)))
([pp] menu-item "Print S-expression" gud-pp
:enable (and (not gud-running)
(bound-and-true-p gdb-active-process))
:visible (and (string-equal
(buffer-local-value
'gud-target-name gud-comint-buffer)
"emacs")
(eq gud-minor-mode 'gdbmi)))
([print*] . (menu-item (if (eq gud-minor-mode 'jdb)
"Dump object"
"Print Dereference")
gud-pstar
:enable (not gud-running)
:visible (memq gud-minor-mode '(gdbmi gdb jdb))))
([print] menu-item "Print Expression" gud-print
:enable (not gud-running))
([watch] menu-item "Watch Expression" gud-watch
:enable (not gud-running)
:visible (eq gud-minor-mode 'gdbmi))
([finish] menu-item "Finish Function" gud-finish
:enable (not gud-running)
:visible (memq gud-minor-mode
'(gdbmi gdb guiler xdb jdb pdb)))
([stepi] menu-item "Step Instruction" gud-stepi
:enable (not gud-running)
:visible (memq gud-minor-mode '(gdbmi gdb dbx)))
([nexti] menu-item "Next Instruction" gud-nexti
:enable (not gud-running)
:visible (memq gud-minor-mode '(gdbmi gdb dbx)))
([step] menu-item "Step Line" gud-step
:enable (not gud-running))
([next] menu-item "Next Line" gud-next
:enable (not gud-running))
([cont] menu-item "Continue" gud-cont
:enable (not gud-running)
:visible (not (eq gud-minor-mode 'gdbmi))))
"Menu for `gud-mode'." "Menu for `gud-mode'."
'("Gud" :name "Gud")
["Continue" gud-cont
:enable (not gud-running) (easy-mmode-defmap gud-minor-mode-map
:visible (not (eq gud-minor-mode 'gdbmi))] (append
["Next Line" gud-next `(([menu-bar debug] . ("Gud" . ,gud-menu-map)))
:enable (not gud-running)] ;; Get tool bar like functionality from the menu bar on a text only
["Step Line" gud-step ;; terminal.
:enable (not gud-running)] (unless window-system
["Next Instruction" gud-nexti `(([menu-bar down]
:enable (not gud-running) . (,(propertize "down" 'face 'font-lock-doc-face) . gud-down))
:visible (memq gud-minor-mode '(gdbmi gdb dbx))] ([menu-bar up]
["Step Instruction" gud-stepi . (,(propertize "up" 'face 'font-lock-doc-face) . gud-up))
:enable (not gud-running) ([menu-bar finish]
:visible (memq gud-minor-mode '(gdbmi gdb dbx))] . (,(propertize "finish" 'face 'font-lock-doc-face) . gud-finish))
["Finish Function" gud-finish ([menu-bar step]
:enable (not gud-running) . (,(propertize "step" 'face 'font-lock-doc-face) . gud-step))
:visible (memq gud-minor-mode '(gdbmi gdb guiler xdb jdb pdb))] ([menu-bar next]
["Watch Expression" gud-watch . (,(propertize "next" 'face 'font-lock-doc-face) . gud-next))
:enable (not gud-running) ([menu-bar until] menu-item
:visible (eq gud-minor-mode 'gdbmi)] ,(propertize "until" 'face 'font-lock-doc-face) gud-until
["Print Expression" gud-print :visible (memq gud-minor-mode '(gdbmi gdb perldb)))
:enable (not gud-running)] ([menu-bar cont] menu-item
["Dump object-Derefenrece" gud-pstar ,(propertize "cont" 'face 'font-lock-doc-face) gud-cont
:label (if (eq gud-minor-mode 'jdb) :visible (not (eq gud-minor-mode 'gdbmi)))
"Dump object" ([menu-bar run] menu-item
"Print Dereference") ,(propertize "run" 'face 'font-lock-doc-face) gud-run
:enable (not gud-running) :visible (memq gud-minor-mode '(gdbmi gdb dbx jdb)))
:visible (memq gud-minor-mode '(gdbmi gdb jdb))] ([menu-bar go] menu-item
["Print S-expression" gud-pp ,(propertize " go " 'face 'font-lock-doc-face) gud-go
:enable (and (not gud-running) :visible (and (eq gud-minor-mode 'gdbmi)
(bound-and-true-p gdb-active-process)) (gdb-show-run-p)))
:visible (and (string-equal ([menu-bar stop] menu-item
(buffer-local-value ,(propertize "stop" 'face 'font-lock-doc-face) gud-stop-subjob
'gud-target-name gud-comint-buffer) :visible (or (and (eq gud-minor-mode 'gdbmi)
"emacs") (gdb-show-stop-p))
(eq gud-minor-mode 'gdbmi))] (not (eq gud-minor-mode 'gdbmi))))
["Down Stack" gud-down ([menu-bar print]
:enable (not gud-running) . (,(propertize "print" 'face 'font-lock-doc-face) . gud-print))
:visible (memq gud-minor-mode '(gdbmi gdb guiler dbx xdb jdb pdb))] ([menu-bar tools] . undefined)
["Up Stack" gud-up ([menu-bar buffer] . undefined)
:enable (not gud-running) ([menu-bar options] . undefined)
:visible (memq gud-minor-mode ([menu-bar edit] . undefined)
'(gdbmi gdb guiler dbx xdb jdb pdb))] ([menu-bar file] . undefined))))
["Set Breakpoint" gud-break "Map used in visited files.")
:enable (not gud-running)
:visible (gud-tool-bar-item-visible-no-fringe)] (setf (alist-get 'gud-minor-mode minor-mode-map-alist)
["Temporary Breakpoint" gud-tbreak gud-minor-mode-map)
:enable (not gud-running)
:visible (memq gud-minor-mode '(gdbmi gdb sdb xdb))] (defvar gud-mode-map
["Remove Breakpoint" gud-remove ;; Will inherit from comint-mode via define-derived-mode.
:enable (not gud-running) (make-sparse-keymap)
:visible (gud-tool-bar-item-visible-no-fringe)] "`gud-mode' keymap.")
["Continue to selection" gud-until
:enable (not gud-running)
:visible (and (memq gud-minor-mode '(gdbmi gdb perldb))
(gud-tool-bar-item-visible-no-fringe))]
["Stop" gud-stop-subjob
:visible (or (not (memq gud-minor-mode '(gdbmi pdb)))
(and (eq gud-minor-mode 'gdbmi)
(gdb-show-stop-p)))]
["Continue-Run" gud-go
:label (if (bound-and-true-p gdb-active-process)
"Continue" "Run")
:visible (and (eq gud-minor-mode 'gdbmi)
(gdb-show-run-p))]
["Run" gud-run
:enable (not gud-running)
:visible (or (memq gud-minor-mode '(gdb dbx jdb))
(and (eq gud-minor-mode 'gdbmi)
(or (not (gdb-show-run-p))
(bound-and-true-p
gdb-active-process))))]
["Refresh" gud-refresh]
["Show GUD tooltips" gud-tooltip-mode
:enable (and (not emacs-basic-display)
(display-graphic-p)
(fboundp 'x-show-tip))
:visible (memq gud-minor-mode
'(gdbmi guiler dbx sdb xdb pdb))
:button (:toggle . gud-tooltip-mode)]
["Info (debugger)" gud-goto-info]))
(setf (alist-get 'gud-minor-mode minor-mode-map-alist) (setf (alist-get 'gud-minor-mode minor-mode-map-alist)
gud-minor-mode-map) gud-minor-mode-map)