GNU bug report logs - #47688
28.0.50; repeat-mode: Make rectangle commands repeatable. Also some misc. queries, comments

Previous Next

Package: emacs;

Reported by: Ramesh Nedunchezian <rameshnedunchezian <at> outlook.com>

Date: Sat, 10 Apr 2021 08:24:02 UTC

Severity: normal

Found in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 47688 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Ramesh Nedunchezian <rameshnedunchezian <at> outlook.com>
Cc: 47688 <at> debbugs.gnu.org
Subject: Re: 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
[Message part 1 (text/plain, inline)]
> 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 ...'

[gud-step-repeat-map.patch (text/x-diff, inline)]
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)
[Message part 3 (text/plain, inline)]
Also you can see that adding a convenience macro wouldn't much of help here,
dolist is quite convenient as well.

This bug report was last modified 4 years and 15 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.