diff options
author | Brian Leung <leungbk@mailfence.com> | 2021-07-19 23:41:01 -0700 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-07-28 00:13:40 +0300 |
commit | 29d62099957b2269c2505be3a9059c88d2d71881 (patch) | |
tree | f24050e3043dfaa5fbb461fce4037e7e861ef203 /lisp/progmodes/gud.el | |
parent | 30bd6a50aa4cf1cb486b40876fd42bd5da74e77a (diff) | |
download | emacs-29d62099957b2269c2505be3a9059c88d2d71881.tar.gz |
Ensure that gud commands for M-x gdb are handled by repeat-mode
* lisp/progmodes/gud.el (gud-gdb-repeat-map): Rename from
gud-repeat-map, and populate at the top-level.
(gud-set-repeat-map-property): Introduce this helper function for
setting the repeat-map property.
(gud-gdb): Use the gud-set-repeat-map-property function to assign the
repeat-map property.
* lisp/progmodes/gdb-mi.el (gdb): Use the gud-set-repeat-map-property
function to assign the repeat-map property.
Because different debugging tools may not support all of the gud-foo
functions, we reassign the repeat-map property within the respective
commands, as opposed to the top level of the files, to ensure that the
repeat-map property is reassigned each time to a symbol corresponding
to the active debugging tool. (Bug#49632)
Diffstat (limited to 'lisp/progmodes/gud.el')
-rw-r--r-- | lisp/progmodes/gud.el | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 740a6e25812..c4413b104bb 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -320,10 +320,32 @@ Used to gray out relevant toolbar icons.") (tool-bar-local-item-from-menu (car x) (cdr x) map gud-minor-mode-map)))) -(defvar gud-repeat-map (make-sparse-keymap) - "Keymap to repeat gud stepping instructions `C-x C-a C-n n n'. +(defvar gud-gdb-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("i" . gud-stepi) + ("c" . gud-cont) + ("l" . gud-refresh) + ("f" . gud-finish) + ("<" . gud-up) + (">" . gud-down))) + (define-key map key cmd)) + map) + "Keymap to repeat `gud-gdb' stepping instructions `C-x C-a C-n n n'. Used in `repeat-mode'.") +(defun gud-set-repeat-map-property (keymap-symbol) + "Set the `repeat-map' property of relevant gud commands to KEYMAP-SYMBOL. + +KEYMAP-SYMBOL is a symbol corresponding to some +`<FOO>-repeat-map', a keymap containing gud commands that may be +repeated when `repeat-mode' is on." + (map-keymap-internal (lambda (_ cmd) + (put cmd 'repeat-map keymap-symbol)) + (symbol-value keymap-symbol))) + + (defun gud-file-name (f) "Transform a relative file name to an absolute file name. Uses `gud-<MINOR-MODE>-directories' to find the source files." @@ -814,16 +836,7 @@ the buffer in which this command was invoked." (gud-def gud-until "until %l" "\C-u" "Continue to current line.") (gud-def gud-run "run" nil "Run the program.") - (dolist (cmd '(("n" . gud-next) - ("s" . gud-step) - ("i" . gud-stepi) - ("c" . gud-cont) - ("l" . gud-refresh) - ("f" . gud-finish) - ("<" . gud-up) - (">" . gud-down))) - (define-key gud-repeat-map (car cmd) (cdr cmd)) - (put (cdr cmd) 'repeat-map 'gud-repeat-map)) + (gud-set-repeat-map-property 'gud-gdb-repeat-map) (add-hook 'completion-at-point-functions #'gud-gdb-completion-at-point nil 'local) |