From bce2187351208f6e5054dd581aba121325717587 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 22 Dec 2024 02:13:07 +0100 Subject: [PATCH] Prefer defvar-keymap in gud.el * lisp/progmodes/gud.el (gud-gdb-repeat-map, gud-sdb-repeat-map) (gud-dbx-repeat-map, gud-xdb-repeat-map, gud-perldb-repeat-map) (gud-pdb-repeat-map, gud-guiler-repeat-map, gud-jdb-repeat-map): Convert to defvar-keymap. (cherry picked from commit d89d8715eeae775305d4c5790b60793e3e57a474) --- lisp/progmodes/gud.el | 186 +++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 104 deletions(-) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 753ebd09d07..bccc00a3941 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -331,20 +331,17 @@ Check it when `gud-running' is t") (tool-bar-local-item-from-menu (car x) (cdr x) map gud-menu-mode-map)))) -(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'.") +(defvar-keymap gud-gdb-repeat-map + :doc "Keymap to repeat `gud-gdb' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "i" #'gud-stepi + "c" #'gud-cont + "l" #'gud-refresh + "f" #'gud-finish + "<" #'gud-up + ">" #'gud-down) (defun gud-set-repeat-map-property (keymap-symbol) "Set the `repeat-map' property of relevant gud commands to KEYMAP-SYMBOL. @@ -1064,17 +1061,14 @@ SKIP is the number of chars to skip on each line, it defaults to 0." (defvar gud-sdb-lastfile nil) -(defvar gud-sdb-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))) - (define-key map key cmd)) - map) - "Keymap to repeat `sdb' stepping instructions \\`C-x C-a C-n n n'. -Used in `repeat-mode'.") +(defvar-keymap gud-sdb-repeat-map + :doc "Keymap to repeat `sdb' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "i" #'gud-stepi + "c" #'gud-cont + "l" #'gud-refresh) (defun gud-sdb-marker-filter (string) (setq gud-marker-acc @@ -1306,22 +1300,21 @@ whereby $stopformat=1 produces an output format compatible with ;; whereby `set $stopformat=1' reportedly produces output compatible ;; with `gud-dbx-marker-filter', which we prefer. -(defvar gud-dbx-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) - ("<" . gud-up) - (">" . gud-down))) - (define-key map key cmd)) - (when (or gud-mips-p - gud-irix-p) - (define-key map "f" #'gud-finish)) - map) - "Keymap to repeat `dbx' stepping instructions \\`C-x C-a C-n n n'. -Used in `repeat-mode'.") +(defvar-keymap gud-dbx-repeat-map + :doc "Keymap to repeat `dbx' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "i" #'gud-stepi + "c" #'gud-cont + "l" #'gud-refresh + "<" #'gud-up + ">" #'gud-down) + +(when (or gud-mips-p + gud-irix-p) + (keymap-set gud-dbx-repeat-map "f" #'gud-finish)) + ;; The process filter is also somewhat ;; unreliable, sometimes not spotting the markers; I don't know @@ -1483,20 +1476,17 @@ and source-file directory for your debugger." ;; History of argument lists passed to xdb. (defvar gud-xdb-history nil) -(defvar gud-xdb-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 `xdb' stepping instructions \\`C-x C-a C-n n n'. -Used in `repeat-mode'.") +(defvar-keymap gud-xdb-repeat-map + :doc "Keymap to repeat `xdb' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "i" #'gud-stepi + "c" #'gud-cont + "l" #'gud-refresh + "f" #'gud-finish + "<" #'gud-up + ">" #'gud-down) (defcustom gud-xdb-directories nil "A list of directories that xdb should search for source code. @@ -1575,16 +1565,13 @@ directories if your program contains sources from more than one directory." ;; History of argument lists passed to perldb. (defvar gud-perldb-history nil) -(defvar gud-perldb-repeat-map - (let ((map (make-sparse-keymap))) - (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) - ("s" . gud-step) - ("c" . gud-cont) - ("l" . gud-refresh))) - (define-key map key cmd)) - map) - "Keymap to repeat `perldb' stepping instructions \\`C-x C-a C-n n n'. -Used in `repeat-mode'.") +(defvar-keymap gud-perldb-repeat-map + :doc "Keymap to repeat `perldb' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "c" #'gud-cont + "l" #'gud-refresh) (defun gud-perldb-massage-args (_file args) "Convert a command line as would be typed normally to run perldb @@ -1763,19 +1750,16 @@ working directory and source-file directory for your debugger." (defvar gud-pdb-marker-regexp-start "^> ") -(defvar gud-pdb-repeat-map - (let ((map (make-sparse-keymap))) - (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) - ("s" . gud-step) - ("c" . gud-cont) - ("l" . gud-refresh) - ("f" . gud-finish) - ("<" . gud-up) - (">" . gud-down))) - (define-key map key cmd)) - map) - "Keymap to repeat `pdb' stepping instructions \\`C-x C-a C-n n n'. -Used in `repeat-mode'.") +(defvar-keymap gud-pdb-repeat-map + :doc "Keymap to repeat `pdb' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "c" #'gud-cont + "l" #'gud-refresh + "f" #'gud-finish + "<" #'gud-up + ">" #'gud-down) ;; There's no guarantee that Emacs will hand the filter the entire ;; marker at once; it could be broken up across several strings. We @@ -1881,18 +1865,15 @@ directory and source-file directory for your debugger." (defvar gud-guiler-lastfile nil) -(defvar gud-guiler-repeat-map - (let ((map (make-sparse-keymap))) - (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) - ("s" . gud-step) - ("l" . gud-refresh) - ("f" . gud-finish) - ("<" . gud-up) - (">" . gud-down))) - (define-key map key cmd)) - map) - "Keymap to repeat `guiler' stepping instructions \\`C-x C-a C-n n n'. -Used in `repeat-mode'.") +(defvar-keymap gud-guiler-repeat-map + :doc "Keymap to repeat `guiler' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "l" #'gud-refresh + "f" #'gud-finish + "<" #'gud-up + ">" #'gud-down) (defun gud-guiler-marker-filter (string) (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string)) @@ -2406,20 +2387,17 @@ extension EXTN. Normally EXTN is given as the regular expression ;; Note: Reset to this value every time a prompt is seen (defvar gud-jdb-lowest-stack-level 999) -(defvar gud-jdb-repeat-map - (let ((map (make-sparse-keymap))) - (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) - ("s" . gud-step) - ("i" . gud-stepi) - ("c" . gud-cont) - ("f" . gud-finish) - ("<" . gud-up) - (">" . gud-down) - ("l" . gud-refresh))) - (define-key map key cmd)) - map) - "Keymap to repeat `jdb' stepping instructions \\`C-x C-a C-n n n'. -Used in `repeat-mode'.") +(defvar-keymap gud-jdb-repeat-map + :doc "Keymap to repeat `jdb' stepping instructions \\`C-x C-a C-n n n'. +Used in `repeat-mode'." + "n" #'gud-next + "s" #'gud-step + "i" #'gud-stepi + "c" #'gud-cont + "f" #'gud-finish + "<" #'gud-up + ">" #'gud-down + "l" #'gud-refresh) (defun gud-jdb-find-source-using-classpath (p) "Find source file corresponding to fully qualified class P. -- 2.39.5