bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47688: 28.0.50; repeat-mode: Make rectangle commands repeatable. Als


From: Juri Linkov
Subject: bug#47688: 28.0.50; repeat-mode: Make rectangle commands repeatable. Also some misc. queries, comments
Date: Tue, 13 Apr 2021 19:09:07 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> Could you please demonstrate an example of the real key sequences
> where repeat-mode could help to greatly reduce the length of
> such key sequences.

An example where such repeating map is sorely missing is gdb.
Until now, stepping through the program was a hassle that required
typing such overly long key sequences:

  'C-x C-a C-n C-x C-a C-n C-x C-a C-n C-x C-a C-n C-x C-a C-n ...'

Now with the following patch, stepping is much easier:

  'C-x C-a C-n n n n n ...'

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index b105cbaa0e..45ba9fff07 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -293,6 +293,12 @@ gud-tool-bar-map
       (tool-bar-local-item-from-menu
        (car x) (cdr x) map gud-minor-mode-map))))
 
+(defvar gud-step-repeat-map
+  (let ((map (make-sparse-keymap)))
+    map)
+  "Keymap to repeat gud stepping instructions `C-x C-a C-n n n'.
+Used in `repeat-mode'.")
+
 (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."
@@ -784,6 +790,17 @@ gud-gdb
   (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-step-repeat-map (car cmd) (cdr cmd))
+    (put (cdr cmd) 'repeat-map 'gud-step-repeat-map))
+
   (add-hook 'completion-at-point-functions #'gud-gdb-completion-at-point
             nil 'local)
   (setq-local gud-gdb-completion-function 'gud-gdb-completions)
Also you can see that adding a convenience macro wouldn't much of help here,
dolist is quite convenient as well.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]