unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
@ 2021-07-19  3:37 Brian Leung
  2021-07-19 13:06 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 20+ messages in thread
From: Brian Leung @ 2021-07-19  3:37 UTC (permalink / raw)
  To: 49632

[-- Attachment #1: Type: text/plain, Size: 58 bytes --]

See attached.

-- 
Mailfence.com
Private and secure email

[-- Attachment #2: File Attachment: 0001-Ensure-that-M-x-gdb-populates-gud-repeat-map.patch --]
[-- Type: text/x-diff, Size: 1330 bytes --]

From c288290de6185e3b23f295b32843c2fc7d4a7049 Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Sun, 18 Jul 2021 20:14:50 -0700
Subject: [PATCH] Ensure that M-x gdb populates gud-repeat-map

* lisp/progmodes/gdb-mi.el (gdb): Populate gud-repeat-map. This is
copied from the gud-gdb command.
---
 lisp/progmodes/gdb-mi.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index aa3365278c..d6a2bce334 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -979,6 +979,17 @@ gdb
   (define-key gud-minor-mode-map [left-margin C-mouse-3]
     'gdb-mouse-jump)
 
+  (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 gud-repeat-map key cmd)
+    (put cmd 'repeat-map 'gud-repeat-map))
+
   (setq-local gud-gdb-completion-function 'gud-gdbmi-completions)
 
   (add-hook 'completion-at-point-functions #'gud-gdb-completion-at-point
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19  3:37 bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map Brian Leung
@ 2021-07-19 13:06 ` Lars Ingebrigtsen
  2021-07-19 13:13   ` Eli Zaretskii
  2021-07-19 14:51   ` Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 20+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-19 13:06 UTC (permalink / raw)
  To: Brian Leung; +Cc: 49632, Juri Linkov

Brian Leung <leungbk@mailfence.com> writes:

> * lisp/progmodes/gdb-mi.el (gdb): Populate gud-repeat-map. This is
> copied from the gud-gdb command.

Instead of copying the code, perhaps it should be separated out into its
own function and then called from both places?

But I don't quite understand why gud-repeat-map is populated in the
normal way -- i.e., in `gud-repeat-map' so that users can
redefine/override entries as usual.

Juri?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 13:06 ` Lars Ingebrigtsen
@ 2021-07-19 13:13   ` Eli Zaretskii
  2021-07-19 14:57     ` Brian Leung
  2021-07-19 14:51   ` Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2021-07-19 13:13 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 49632, leungbk, juri

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Mon, 19 Jul 2021 15:06:31 +0200
> Cc: 49632@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
> 
> Brian Leung <leungbk@mailfence.com> writes:
> 
> > * lisp/progmodes/gdb-mi.el (gdb): Populate gud-repeat-map. This is
> > copied from the gud-gdb command.
> 
> Instead of copying the code, perhaps it should be separated out into its
> own function and then called from both places?
> 
> But I don't quite understand why gud-repeat-map is populated in the
> normal way -- i.e., in `gud-repeat-map' so that users can
> redefine/override entries as usual.

I admit I don't understand the rationale for the patch at all.
"M-x gdb" already repeats these commands when you type just RET
into the interaction buffer, so what exactly does this change
do, and how can I see its effect?





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 13:06 ` Lars Ingebrigtsen
  2021-07-19 13:13   ` Eli Zaretskii
@ 2021-07-19 14:51   ` Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-07-19 15:37     ` Juri Linkov
  1 sibling, 1 reply; 20+ messages in thread
From: Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-07-19 14:51 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 49632, Juri Linkov

> But I don't quite understand why gud-repeat-map is populated in the
> normal way -- i.e., in `gud-repeat-map' so that users can
> redefine/override entries as usual.

I think it is presently done this way because things like M-x gdb, M-x pdb, etc. all use their own debugger commands, so we need to re-bind exactly the right ones each time. For example, in M-x perldb, gud-finish, gud-up, and gud-down are all commented out even though gdb clearly supports those functions.

> ----------------------------------------
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Sent: Mon Jul 19 15:06:31 CEST 2021
> To: Brian Leung <leungbk@mailfence.com>
> Cc: <49632@debbugs.gnu.org>, Juri Linkov <juri@linkov.net>
> Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
> 
> 
> Brian Leung <leungbk@mailfence.com> writes:
> 
> > * lisp/progmodes/gdb-mi.el (gdb): Populate gud-repeat-map. This is
> > copied from the gud-gdb command.
> 
> Instead of copying the code, perhaps it should be separated out into its
> own function and then called from both places?
> 
> But I don't quite understand why gud-repeat-map is populated in the
> normal way -- i.e., in `gud-repeat-map' so that users can
> redefine/override entries as usual.
> 
> Juri?
> 
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no


-- 
Sent with https://mailfence.com
Secure and private email

-- 
Mailfence.com
Private and secure email





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 13:13   ` Eli Zaretskii
@ 2021-07-19 14:57     ` Brian Leung
  2021-07-19 16:05       ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Brian Leung @ 2021-07-19 14:57 UTC (permalink / raw)
  To: Eli Zaretskii, Lars Ingebrigtsen; +Cc: 49632, juri

> I admit I don't understand the rationale for the patch at all.
> "M-x gdb" already repeats these commands when you type just RET
> into the interaction buffer, so what exactly does this change
> do, and how can I see its effect?

RET can repeat only the last command (afaik). If instead I want to run, in order:

1. continue
2. next
3. next
4. stepi

then without this patch, I would need to press

1. C-x C-a C-r
2. C-x C-a C-n
3. C-x C-a C-n
4. C-x C-a C-i

if using M-x gdb.

With the patch, I can press:

1. C-x C-a C-r
2. n
3. n
4. i

since the new repeat-mode defines the appropriate repeat map.

> ----------------------------------------
> From: Eli Zaretskii <eliz@gnu.org>
> Sent: Mon Jul 19 15:13:52 CEST 2021
> To: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: <leungbk@mailfence.com>, <49632@debbugs.gnu.org>, <juri@linkov.net>
> Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
> 
> 
> > From: Lars Ingebrigtsen <larsi@gnus.org>
> > Date: Mon, 19 Jul 2021 15:06:31 +0200
> > Cc: 49632@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
> > 
> > Brian Leung <leungbk@mailfence.com> writes:
> > 
> > > * lisp/progmodes/gdb-mi.el (gdb): Populate gud-repeat-map. This is
> > > copied from the gud-gdb command.
> > 
> > Instead of copying the code, perhaps it should be separated out into its
> > own function and then called from both places?
> > 
> > But I don't quite understand why gud-repeat-map is populated in the
> > normal way -- i.e., in `gud-repeat-map' so that users can
> > redefine/override entries as usual.
> 
> I admit I don't understand the rationale for the patch at all.
> "M-x gdb" already repeats these commands when you type just RET
> into the interaction buffer, so what exactly does this change
> do, and how can I see its effect?


-- 
Sent with https://mailfence.com
Secure and private email

-- 
Mailfence.com
Private and secure email





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 14:51   ` Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-07-19 15:37     ` Juri Linkov
  2021-07-19 15:52       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2021-07-19 15:37 UTC (permalink / raw)
  To: Brian Leung; +Cc: Lars Ingebrigtsen, 49632

>> But I don't quite understand why gud-repeat-map is populated in the
>> normal way -- i.e., in `gud-repeat-map' so that users can
>> redefine/override entries as usual.
>
> I think it is presently done this way because things like M-x gdb, M-x pdb,
> etc. all use their own debugger commands, so we need to re-bind exactly the
> right ones each time. For example, in M-x perldb, gud-finish, gud-up, and
> gud-down are all commented out even though gdb clearly supports
> those functions.

Exactly.  But this means that you need to populate a new separate map
'gdb-repeat-map' specific to 'gdb' commands.  Also I noticed that the
current name of 'gud-repeat-map' is wrong.  It should be renamed to
'gud-gdb-repeat-map'.  So other debuggers could populate own repeat-maps
named e.g. 'sdb-repeat-map', 'jdb-repeat-map', 'perldb-repeat-map', etc.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 15:37     ` Juri Linkov
@ 2021-07-19 15:52       ` Lars Ingebrigtsen
  2021-07-24  3:33         ` Brian Leung
  0 siblings, 1 reply; 20+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-19 15:52 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 49632, Brian Leung

Juri Linkov <juri@linkov.net> writes:

> Exactly.  But this means that you need to populate a new separate map
> 'gdb-repeat-map' specific to 'gdb' commands.  Also I noticed that the
> current name of 'gud-repeat-map' is wrong.  It should be renamed to
> 'gud-gdb-repeat-map'.  So other debuggers could populate own repeat-maps
> named e.g. 'sdb-repeat-map', 'jdb-repeat-map', 'perldb-repeat-map', etc.

I see.  Then Brian's patch is functionally correct, but it shouldn't be
copy-and-pasted -- instead separating it out into a helper function and
using it both places seems like the correct thing to do.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 14:57     ` Brian Leung
@ 2021-07-19 16:05       ` Eli Zaretskii
  2021-07-19 21:53         ` Juri Linkov
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2021-07-19 16:05 UTC (permalink / raw)
  To: Brian Leung; +Cc: larsi, 49632, juri

> Date: Mon, 19 Jul 2021 16:57:11 +0200 (CEST)
> From: Brian Leung <leungbk@mailfence.com>
> Cc: 49632@debbugs.gnu.org, juri@linkov.net
> 
> RET can repeat only the last command (afaik). If instead I want to run, in order:
> 
> 1. continue
> 2. next
> 3. next
> 4. stepi
> 
> then without this patch, I would need to press
> 
> 1. C-x C-a C-r
> 2. C-x C-a C-n
> 3. C-x C-a C-n
> 4. C-x C-a C-i
> 
> if using M-x gdb.

I would instead use M-p (one or more times), then RET.  Isn't it
better, especially since it works when using GDB's own CLI prompt?

Or did you mean you want to invoke these commands in the program
source buffer, not in the GUD interaction buffer?  But in that case,
how do I exit the repeat-mode, to be able to edit the sources?





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 16:05       ` Eli Zaretskii
@ 2021-07-19 21:53         ` Juri Linkov
  0 siblings, 0 replies; 20+ messages in thread
From: Juri Linkov @ 2021-07-19 21:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, 49632, Brian Leung

>> RET can repeat only the last command (afaik). If instead I want to run, in order:
>> 
>> 1. continue
>> 2. next
>> 3. next
>> 4. stepi
>> 
>> then without this patch, I would need to press
>> 
>> 1. C-x C-a C-r
>> 2. C-x C-a C-n
>> 3. C-x C-a C-n
>> 4. C-x C-a C-i
>> 
>> if using M-x gdb.
>
> I would instead use M-p (one or more times), then RET.  Isn't it
> better, especially since it works when using GDB's own CLI prompt?
>
> Or did you mean you want to invoke these commands in the program
> source buffer, not in the GUD interaction buffer?  But in that case,
> how do I exit the repeat-mode, to be able to edit the sources?

'repeat-mode' provides several ways to exit it:

1. type a non-repeatable key (like a non-isearch key exits isearch-mode);
2. customize repeat-exit-key e.g. to RET (then RET exits like in isearch-mode);
3. customize repeat-exit-timeout to exit after a timeout.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-19 15:52       ` Lars Ingebrigtsen
@ 2021-07-24  3:33         ` Brian Leung
  2021-07-25  6:26           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 20+ messages in thread
From: Brian Leung @ 2021-07-24  3:33 UTC (permalink / raw)
  To: Juri Linkov, Lars Ingebrigtsen; +Cc: 49632

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

OK, I've updated the patch following Juri's suggestions.

> ----------------------------------------
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Sent: Mon Jul 19 17:52:43 CEST 2021
> To: Juri Linkov <juri@linkov.net>
> Cc: Brian Leung <leungbk@mailfence.com>, <49632@debbugs.gnu.org>
> Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
> 
> 
> Juri Linkov <juri@linkov.net> writes:
> 
> > Exactly.  But this means that you need to populate a new separate map
> > 'gdb-repeat-map' specific to 'gdb' commands.  Also I noticed that the
> > current name of 'gud-repeat-map' is wrong.  It should be renamed to
> > 'gud-gdb-repeat-map'.  So other debuggers could populate own repeat-maps
> > named e.g. 'sdb-repeat-map', 'jdb-repeat-map', 'perldb-repeat-map', etc.
> 
> I see.  Then Brian's patch is functionally correct, but it shouldn't be
> copy-and-pasted -- instead separating it out into a helper function and
> using it both places seems like the correct thing to do.
> 
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no


-- 
Sent with https://mailfence.com
Secure and private email

-- 
Mailfence.com
Private and secure email

[-- Attachment #2: File Attachment: 0001-Ensure-that-gud-commands-for-M-x-gdb-are-handled-by-.patch --]
[-- Type: text/x-diff, Size: 3737 bytes --]

From 14d770b2f1df8ec9cdb7b1ef60e7870b3e3f849d Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Mon, 19 Jul 2021 23:41:01 -0700
Subject: [PATCH 1/2] 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.
---
 lisp/progmodes/gdb-mi.el |  2 ++
 lisp/progmodes/gud.el    | 32 ++++++++++++++++++++------------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index aa3365278c..28892f9c96 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -979,6 +979,8 @@ gdb
   (define-key gud-minor-mode-map [left-margin C-mouse-3]
     'gdb-mouse-jump)
 
+  (gud-set-repeat-map-property gud-gdb-repeat-map)
+
   (setq-local gud-gdb-completion-function 'gud-gdbmi-completions)
 
   (add-hook 'completion-at-point-functions #'gud-gdb-completion-at-point
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 740a6e2581..402833025f 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -320,10 +320,27 @@ gud-tool-bar-map
       (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'.")
 
+(defmacro gud-set-repeat-map-property (keymap)
+  "Set the `repeat-map' property of each command in KEYMAP to KEYMAP."
+  `(map-keymap-internal (lambda (_ cmd)
+                          (put cmd 'repeat-map ',keymap))
+                        ,keymap))
+
 (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 +831,7 @@ 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-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)
-- 
2.32.0


[-- Attachment #3: File Attachment: 0002-Ensure-that-gud-commands-for-non-GDB-debuggers-are-h.patch --]
[-- Type: text/x-diff, Size: 9684 bytes --]

From fa6428ff8995b864c8b65aa218d1085372bd3994 Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Tue, 20 Jul 2021 00:32:34 -0700
Subject: [PATCH 2/2] Ensure that gud commands for non-GDB debuggers are
 handled by repeat-mode

* lisp/progmodes/gud.el (sdb-repeat-map): Define.
(sdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(dbx-repeat-map): Define.
(dbx): Set repeat-mode property to the symbol corresponding to the
repeat map.
(xdb-repeat-map): Define.
(xdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(perldb-repeat-map): Define.
(perldb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(pdb-repeat-map): Define.
(pdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(guiler-repeat-map): Define.
(guiler): Set repeat-mode property to the symbol corresponding to the
repeat map.
(jdb-repeat-map): Define.
(jdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
---
 lisp/progmodes/gud.el | 110 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 402833025f..eefaddc01b 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -1032,6 +1032,18 @@ gud-sdb-needs-tags
 
 (defvar gud-sdb-lastfile nil)
 
+(defvar 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'.")
+
 (defun gud-sdb-marker-filter (string)
   (setq gud-marker-acc
 	(if gud-marker-acc (concat gud-marker-acc string) string))
@@ -1102,6 +1114,8 @@ sdb
   (gud-def gud-cont   "c"    "\C-r"   "Continue with display.")
   (gud-def gud-print  "%e/"  "\C-p"   "Evaluate C expression at point.")
 
+  (gud-set-repeat-map-property sdb-repeat-map)
+
   (setq comint-prompt-regexp  "\\(^\\|\n\\)\\*")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'sdb-mode-hook)
@@ -1260,6 +1274,23 @@ gud-dbx-use-stopformat-p
 ;; whereby `set $stopformat=1' reportedly produces output compatible
 ;; with `gud-dbx-marker-filter', which we prefer.
 
+(defvar 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'.")
+
 ;; The process filter is also somewhat
 ;; unreliable, sometimes not spotting the markers; I don't know
 ;; whether there's anything that can be done about that.]
@@ -1407,6 +1438,8 @@ dbx
   (gud-def gud-print  "print %e"  "\C-p" "Evaluate C expression at point.")
   (gud-def gud-run    "run"	     nil    "Run the program.")
 
+  (gud-set-repeat-map-property dbx-repeat-map)
+
   (setq comint-prompt-regexp  "^[^)\n]*dbx) *")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'dbx-mode-hook)
@@ -1418,6 +1451,21 @@ dbx
 ;; History of argument lists passed to xdb.
 (defvar gud-xdb-history nil)
 
+(defvar 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'.")
+
 (defcustom gud-xdb-directories nil
   "A list of directories that xdb should search for source code.
 If nil, only source files in the program directory
@@ -1483,6 +1531,8 @@ xdb
   (gud-def gud-finish "bu\\t"      "\C-f" "Finish executing current function.")
   (gud-def gud-print  "p %e"       "\C-p" "Evaluate C expression at point.")
 
+  (gud-set-repeat-map-property xdb-repeat-map)
+
   (setq comint-prompt-regexp  "^>")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'xdb-mode-hook))
@@ -1493,6 +1543,17 @@ xdb
 ;; History of argument lists passed to perldb.
 (defvar gud-perldb-history nil)
 
+(defvar 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'.")
+
 (defun gud-perldb-massage-args (_file args)
   "Convert a command line as would be typed normally to run perldb
 into one that invokes an Emacs-enabled debugging session.
@@ -1635,6 +1696,7 @@ perldb
   (gud-def gud-print  "p %e"          "\C-p" "Evaluate perl expression at point.")
   (gud-def gud-until  "c %l"          "\C-u" "Continue to current line.")
 
+  (gud-set-repeat-map-property perldb-repeat-map)
 
   (setq comint-prompt-regexp "^  DB<+[0-9]+>+ ")
   (setq paragraph-start comint-prompt-regexp)
@@ -1663,6 +1725,20 @@ gud-pdb-marker-regexp-fnname-group
 
 (defvar gud-pdb-marker-regexp-start "^> ")
 
+(defvar 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'.")
+
 ;; There's no guarantee that Emacs will hand the filter the entire
 ;; marker at once; it could be broken up across several strings.  We
 ;; might even receive a big chunk with several markers in it.  If we
@@ -1752,6 +1828,8 @@ pdb
   (gud-def gud-print  "p %e"         "\C-p" "Evaluate Python expression at point.")
   (gud-def gud-statement "!%e"      "\C-e" "Execute Python statement at point.")
 
+  (gud-set-repeat-map-property pdb-repeat-map)
+
   ;; (setq comint-prompt-regexp "^(.*pdb[+]?) *")
   (setq comint-prompt-regexp "^(Pdb) *")
   (setq paragraph-start comint-prompt-regexp)
@@ -1765,6 +1843,19 @@ gud-guiler-history
 
 (defvar gud-guiler-lastfile nil)
 
+(defvar 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'.")
+
 (defun gud-guiler-marker-filter (string)
   (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string))
 
@@ -1830,6 +1921,8 @@ guiler
   (gud-def gud-down   ",down"         ">" "Down one stack frame.")
   (gud-def gud-print  "%e"            "\C-p" "Evaluate Guile expression at point.")
 
+  (gud-set-repeat-map-property guiler-repeat-map)
+
   (setq comint-prompt-regexp "^scheme@([^>]+> ")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'guiler-mode-hook))
@@ -2275,6 +2368,21 @@ gud-jdb-find-source-file
 ;; Note: Reset to this value every time a prompt is seen
 (defvar gud-jdb-lowest-stack-level 999)
 
+(defvar 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'.")
+
 (defun gud-jdb-find-source-using-classpath (p)
   "Find source file corresponding to fully qualified class P.
 Convert P from jdb's output, converted to a pathname
@@ -2483,6 +2591,8 @@ jdb
   (gud-def gud-print  "print %e"  "\C-p" "Print value of expression at point.")
   (gud-def gud-pstar  "dump %e"  nil "Print all object information at point.")
 
+  (gud-set-repeat-map-property jdb-repeat-map)
+
   (setq comint-prompt-regexp "^> \\|^[^ ]+\\[[0-9]+\\] ")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'jdb-mode-hook)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-24  3:33         ` Brian Leung
@ 2021-07-25  6:26           ` Lars Ingebrigtsen
  2021-07-25 20:53             ` Juri Linkov
  0 siblings, 1 reply; 20+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-25  6:26 UTC (permalink / raw)
  To: Brian Leung; +Cc: 49632, Juri Linkov

Brian Leung <leungbk@mailfence.com> writes:

> OK, I've updated the patch following Juri's suggestions.

Skimming the patch, it looks good to me.  Juri, do you have any
comments?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-25  6:26           ` Lars Ingebrigtsen
@ 2021-07-25 20:53             ` Juri Linkov
  2021-07-25 21:28               ` Brian Leung
  0 siblings, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2021-07-25 20:53 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 49632, Brian Leung

>> OK, I've updated the patch following Juri's suggestions.
>
> Skimming the patch, it looks good to me.  Juri, do you have any
> comments?

There is one thing that I don't understand: is the
helper function gud-set-repeat-map-property really needed?

If e.g. the defvar gud-gdb-repeat-map uses such symbols as 'gud-next',
could it put the 'repeat-map' property on the same symbols
with reference to the variable 'map' directly in these defvars?
Then only defvars will be needed, and no changes in gud-gdb, gdb.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-25 20:53             ` Juri Linkov
@ 2021-07-25 21:28               ` Brian Leung
  2021-07-26 22:48                 ` Juri Linkov
  0 siblings, 1 reply; 20+ messages in thread
From: Brian Leung @ 2021-07-25 21:28 UTC (permalink / raw)
  To: Juri Linkov, Lars Ingebrigtsen; +Cc: 49632

> There is one thing that I don't understand: is the
> helper function gud-set-repeat-map-property really needed?
> 
> If e.g. the defvar gud-gdb-repeat-map uses such symbols as 'gud-next',
> could it put the 'repeat-map' property on the same symbols
> with reference to the variable 'map' directly in these defvars?
> Then only defvars will be needed, and no changes in gud-gdb, gdb.

If we assign the repeat-map property within the defvars and avoid doing so in the M-x gdb commands, then after gud.el gets loaded, the repeat-map property on (say) gud-next will be 'jdb, since jdb-repeat-map is the last such foo-repeat-map defvar appearing in gud.el. In that case, calling M-x perldb and then running gud-next when repeat-mode is on will bring up the jdb-repeat-map, which contains some commands that aren't defined for perldb. So I think the gud-set-repeat-map-property macro (or something like it) is necessary.

> ----------------------------------------
> From: Juri Linkov <juri@linkov.net>
> Sent: Sun Jul 25 22:53:31 CEST 2021
> To: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Brian Leung <leungbk@mailfence.com>, <49632@debbugs.gnu.org>
> Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
> 
> 
> >> OK, I've updated the patch following Juri's suggestions.
> >
> > Skimming the patch, it looks good to me.  Juri, do you have any
> > comments?
> 
> There is one thing that I don't understand: is the
> helper function gud-set-repeat-map-property really needed?
> 
> If e.g. the defvar gud-gdb-repeat-map uses such symbols as 'gud-next',
> could it put the 'repeat-map' property on the same symbols
> with reference to the variable 'map' directly in these defvars?
> Then only defvars will be needed, and no changes in gud-gdb, gdb.


-- 
Sent with https://mailfence.com
Secure and private email

-- 
Mailfence.com
Private and secure email





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-25 21:28               ` Brian Leung
@ 2021-07-26 22:48                 ` Juri Linkov
  2021-07-27  4:09                   ` Brian Leung
  0 siblings, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2021-07-26 22:48 UTC (permalink / raw)
  To: Brian Leung; +Cc: Lars Ingebrigtsen, 49632

>> There is one thing that I don't understand: is the
>> helper function gud-set-repeat-map-property really needed?
>>
>> If e.g. the defvar gud-gdb-repeat-map uses such symbols as 'gud-next',
>> could it put the 'repeat-map' property on the same symbols
>> with reference to the variable 'map' directly in these defvars?
>> Then only defvars will be needed, and no changes in gud-gdb, gdb.
>
> If we assign the repeat-map property within the defvars and avoid doing so
> in the M-x gdb commands, then after gud.el gets loaded, the repeat-map
> property on (say) gud-next will be 'jdb, since jdb-repeat-map is the last
> such foo-repeat-map defvar appearing in gud.el. In that case, calling M-x
> perldb and then running gud-next when repeat-mode is on will bring up the
> jdb-repeat-map, which contains some commands that aren't defined for
> perldb. So I think the gud-set-repeat-map-property macro (or something like
> it) is necessary.

You are right.  Then I have only minor comments:

1. I thought that you want to create two separate maps for gud-gdb and gdb.
This is the reason why I suggested to rename gud-repeat-map to gud-gdb-repeat-map.
But since you use only one map for gbd and gud-gdb, then the name
gud-repeat-map is fine.

2. Is there a reason why gud-set-repeat-map-property should be a macro,
but not a function?  When it's a macro, there are problems such that
when the user modifies the map, then the function that uses the macro
needs to be recompiled.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-26 22:48                 ` Juri Linkov
@ 2021-07-27  4:09                   ` Brian Leung
  2021-07-27  6:46                     ` Brian Leung
  0 siblings, 1 reply; 20+ messages in thread
From: Brian Leung @ 2021-07-27  4:09 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 49632

[-- Attachment #1: Type: text/plain, Size: 2675 bytes --]

> Is there a reason why gud-set-repeat-map-property should be a macro,
> but not a function?  When it's a macro, there are problems such that
> when the user modifies the map, then the function that uses the macro
> needs to be recompiled.

When I wrote initially wrote gud-set-repeat-map-property, I couldn't figure out how to make gud-set-repeat-map-property work as a function since the repeat-map property needed to be a symbol corresponding to a keymap, and not an evaluated keymap.

I've updated the patch with a change to the repeat-post-hook function in repeat.el to accept an evaluated keymap, which permits a function version of gud-set-repeat-map-property.

> ----------------------------------------
> From: Juri Linkov <juri@linkov.net>
> Sent: Tue Jul 27 00:48:20 CEST 2021
> To: Brian Leung <leungbk@mailfence.com>
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, <49632@debbugs.gnu.org>
> Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
> 
> 
> >> There is one thing that I don't understand: is the
> >> helper function gud-set-repeat-map-property really needed?
> >>
> >> If e.g. the defvar gud-gdb-repeat-map uses such symbols as 'gud-next',
> >> could it put the 'repeat-map' property on the same symbols
> >> with reference to the variable 'map' directly in these defvars?
> >> Then only defvars will be needed, and no changes in gud-gdb, gdb.
> >
> > If we assign the repeat-map property within the defvars and avoid doing so
> > in the M-x gdb commands, then after gud.el gets loaded, the repeat-map
> > property on (say) gud-next will be 'jdb, since jdb-repeat-map is the last
> > such foo-repeat-map defvar appearing in gud.el. In that case, calling M-x
> > perldb and then running gud-next when repeat-mode is on will bring up the
> > jdb-repeat-map, which contains some commands that aren't defined for
> > perldb. So I think the gud-set-repeat-map-property macro (or something like
> > it) is necessary.
> 
> You are right.  Then I have only minor comments:
> 
> 1. I thought that you want to create two separate maps for gud-gdb and gdb.
> This is the reason why I suggested to rename gud-repeat-map to gud-gdb-repeat-map.
> But since you use only one map for gbd and gud-gdb, then the name
> gud-repeat-map is fine.
> 
> 2. Is there a reason why gud-set-repeat-map-property should be a macro,
> but not a function?  When it's a macro, there are problems such that
> when the user modifies the map, then the function that uses the macro
> needs to be recompiled.


-- 
Sent with https://mailfence.com
Secure and private email

-- 
Mailfence.com
Private and secure email

[-- Attachment #2: File Attachment: 0001-Ensure-that-gud-commands-for-M-x-gdb-are-handled-by-.patch --]
[-- Type: text/x-diff, Size: 4396 bytes --]

From d12a32b225c364aa75708c766370e8f27a08995a Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Mon, 19 Jul 2021 23:41:01 -0700
Subject: [PATCH 1/2] 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.

* lisp/repeat.el (repeat-post-hook): Allow the repeat-map property to
be an evaluated keymap.
---
 lisp/progmodes/gdb-mi.el |  2 ++
 lisp/progmodes/gud.el    | 33 +++++++++++++++++++++------------
 lisp/repeat.el           |  3 ++-
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 57c99abec6..ad579eb89f 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -996,6 +996,8 @@ gdb
   (define-key gud-minor-mode-map [left-margin C-mouse-3]
     'gdb-mouse-jump)
 
+  (gud-set-repeat-map-property gud-gdb-repeat-map)
+
   (setq-local gud-gdb-completion-function 'gud-gdbmi-completions)
 
   (add-hook 'completion-at-point-functions #'gud-gdb-completion-at-point
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 740a6e2581..3ffae7f2e0 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -320,10 +320,28 @@ gud-tool-bar-map
       (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)
+  "Set the `repeat-map' property of each command in KEYMAP to KEYMAP."
+  (map-keymap-internal (lambda (_ cmd)
+                          (put cmd 'repeat-map keymap))
+                        keymap))
+
+
 (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 +832,7 @@ 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-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)
diff --git a/lisp/repeat.el b/lisp/repeat.el
index cec3cb643a..aa2c3a0779 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -410,7 +410,8 @@ repeat-post-hook
                          (and (symbolp real-this-command)
                               (get real-this-command 'repeat-map)))))
         (when rep-map
-          (when (boundp rep-map)
+          (when (and (boundp rep-map)
+                     (not (keymapp rep-map)))
             (setq rep-map (symbol-value rep-map)))
           (let ((map (copy-keymap rep-map)))
 
-- 
2.32.0


[-- Attachment #3: File Attachment: 0002-Ensure-that-gud-commands-for-non-GDB-debuggers-are-h.patch --]
[-- Type: text/x-diff, Size: 9684 bytes --]

From 1bc33064c86a7dbeb0330f9aedaa23dfc35495bb Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Tue, 20 Jul 2021 00:32:34 -0700
Subject: [PATCH 2/2] Ensure that gud commands for non-GDB debuggers are
 handled by repeat-mode

* lisp/progmodes/gud.el (sdb-repeat-map): Define.
(sdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(dbx-repeat-map): Define.
(dbx): Set repeat-mode property to the symbol corresponding to the
repeat map.
(xdb-repeat-map): Define.
(xdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(perldb-repeat-map): Define.
(perldb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(pdb-repeat-map): Define.
(pdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(guiler-repeat-map): Define.
(guiler): Set repeat-mode property to the symbol corresponding to the
repeat map.
(jdb-repeat-map): Define.
(jdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
---
 lisp/progmodes/gud.el | 110 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 3ffae7f2e0..950ee356f4 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -1033,6 +1033,18 @@ gud-sdb-needs-tags
 
 (defvar gud-sdb-lastfile nil)
 
+(defvar 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'.")
+
 (defun gud-sdb-marker-filter (string)
   (setq gud-marker-acc
 	(if gud-marker-acc (concat gud-marker-acc string) string))
@@ -1103,6 +1115,8 @@ sdb
   (gud-def gud-cont   "c"    "\C-r"   "Continue with display.")
   (gud-def gud-print  "%e/"  "\C-p"   "Evaluate C expression at point.")
 
+  (gud-set-repeat-map-property sdb-repeat-map)
+
   (setq comint-prompt-regexp  "\\(^\\|\n\\)\\*")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'sdb-mode-hook)
@@ -1261,6 +1275,23 @@ gud-dbx-use-stopformat-p
 ;; whereby `set $stopformat=1' reportedly produces output compatible
 ;; with `gud-dbx-marker-filter', which we prefer.
 
+(defvar 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'.")
+
 ;; The process filter is also somewhat
 ;; unreliable, sometimes not spotting the markers; I don't know
 ;; whether there's anything that can be done about that.]
@@ -1408,6 +1439,8 @@ dbx
   (gud-def gud-print  "print %e"  "\C-p" "Evaluate C expression at point.")
   (gud-def gud-run    "run"	     nil    "Run the program.")
 
+  (gud-set-repeat-map-property dbx-repeat-map)
+
   (setq comint-prompt-regexp  "^[^)\n]*dbx) *")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'dbx-mode-hook)
@@ -1419,6 +1452,21 @@ dbx
 ;; History of argument lists passed to xdb.
 (defvar gud-xdb-history nil)
 
+(defvar 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'.")
+
 (defcustom gud-xdb-directories nil
   "A list of directories that xdb should search for source code.
 If nil, only source files in the program directory
@@ -1484,6 +1532,8 @@ xdb
   (gud-def gud-finish "bu\\t"      "\C-f" "Finish executing current function.")
   (gud-def gud-print  "p %e"       "\C-p" "Evaluate C expression at point.")
 
+  (gud-set-repeat-map-property xdb-repeat-map)
+
   (setq comint-prompt-regexp  "^>")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'xdb-mode-hook))
@@ -1494,6 +1544,17 @@ xdb
 ;; History of argument lists passed to perldb.
 (defvar gud-perldb-history nil)
 
+(defvar 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'.")
+
 (defun gud-perldb-massage-args (_file args)
   "Convert a command line as would be typed normally to run perldb
 into one that invokes an Emacs-enabled debugging session.
@@ -1636,6 +1697,7 @@ perldb
   (gud-def gud-print  "p %e"          "\C-p" "Evaluate perl expression at point.")
   (gud-def gud-until  "c %l"          "\C-u" "Continue to current line.")
 
+  (gud-set-repeat-map-property perldb-repeat-map)
 
   (setq comint-prompt-regexp "^  DB<+[0-9]+>+ ")
   (setq paragraph-start comint-prompt-regexp)
@@ -1664,6 +1726,20 @@ gud-pdb-marker-regexp-fnname-group
 
 (defvar gud-pdb-marker-regexp-start "^> ")
 
+(defvar 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'.")
+
 ;; There's no guarantee that Emacs will hand the filter the entire
 ;; marker at once; it could be broken up across several strings.  We
 ;; might even receive a big chunk with several markers in it.  If we
@@ -1753,6 +1829,8 @@ pdb
   (gud-def gud-print  "p %e"         "\C-p" "Evaluate Python expression at point.")
   (gud-def gud-statement "!%e"      "\C-e" "Execute Python statement at point.")
 
+  (gud-set-repeat-map-property pdb-repeat-map)
+
   ;; (setq comint-prompt-regexp "^(.*pdb[+]?) *")
   (setq comint-prompt-regexp "^(Pdb) *")
   (setq paragraph-start comint-prompt-regexp)
@@ -1766,6 +1844,19 @@ gud-guiler-history
 
 (defvar gud-guiler-lastfile nil)
 
+(defvar 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'.")
+
 (defun gud-guiler-marker-filter (string)
   (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string))
 
@@ -1831,6 +1922,8 @@ guiler
   (gud-def gud-down   ",down"         ">" "Down one stack frame.")
   (gud-def gud-print  "%e"            "\C-p" "Evaluate Guile expression at point.")
 
+  (gud-set-repeat-map-property guiler-repeat-map)
+
   (setq comint-prompt-regexp "^scheme@([^>]+> ")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'guiler-mode-hook))
@@ -2276,6 +2369,21 @@ gud-jdb-find-source-file
 ;; Note: Reset to this value every time a prompt is seen
 (defvar gud-jdb-lowest-stack-level 999)
 
+(defvar 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'.")
+
 (defun gud-jdb-find-source-using-classpath (p)
   "Find source file corresponding to fully qualified class P.
 Convert P from jdb's output, converted to a pathname
@@ -2484,6 +2592,8 @@ jdb
   (gud-def gud-print  "print %e"  "\C-p" "Print value of expression at point.")
   (gud-def gud-pstar  "dump %e"  nil "Print all object information at point.")
 
+  (gud-set-repeat-map-property jdb-repeat-map)
+
   (setq comint-prompt-regexp "^> \\|^[^ ]+\\[[0-9]+\\] ")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'jdb-mode-hook)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-27  4:09                   ` Brian Leung
@ 2021-07-27  6:46                     ` Brian Leung
  2021-07-27 21:15                       ` Juri Linkov
  0 siblings, 1 reply; 20+ messages in thread
From: Brian Leung @ 2021-07-27  6:46 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 49632

[-- Attachment #1: Type: text/plain, Size: 3355 bytes --]

I found a way to make gud-set-repeat-map-property a function without having to change repeat.el. See attached for an updated patch.

> ----------------------------------------
> From: Brian Leung <leungbk@mailfence.com>
> Sent: Tue Jul 27 06:09:14 CEST 2021
> To: Juri Linkov <juri@linkov.net>
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, <49632@debbugs.gnu.org>
> Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
> 
> 
> > Is there a reason why gud-set-repeat-map-property should be a macro,
> > but not a function?  When it's a macro, there are problems such that
> > when the user modifies the map, then the function that uses the macro
> > needs to be recompiled.
> 
> When I wrote initially wrote gud-set-repeat-map-property, I couldn't figure out how to make gud-set-repeat-map-property work as a function since the repeat-map property needed to be a symbol corresponding to a keymap, and not an evaluated keymap.
> 
> I've updated the patch with a change to the repeat-post-hook function in repeat.el to accept an evaluated keymap, which permits a function version of gud-set-repeat-map-property.
> 
> > ----------------------------------------
> > From: Juri Linkov <juri@linkov.net>
> > Sent: Tue Jul 27 00:48:20 CEST 2021
> > To: Brian Leung <leungbk@mailfence.com>
> > Cc: Lars Ingebrigtsen <larsi@gnus.org>, <49632@debbugs.gnu.org>
> > Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
> > 
> > 
> > >> There is one thing that I don't understand: is the
> > >> helper function gud-set-repeat-map-property really needed?
> > >>
> > >> If e.g. the defvar gud-gdb-repeat-map uses such symbols as 'gud-next',
> > >> could it put the 'repeat-map' property on the same symbols
> > >> with reference to the variable 'map' directly in these defvars?
> > >> Then only defvars will be needed, and no changes in gud-gdb, gdb.
> > >
> > > If we assign the repeat-map property within the defvars and avoid doing so
> > > in the M-x gdb commands, then after gud.el gets loaded, the repeat-map
> > > property on (say) gud-next will be 'jdb, since jdb-repeat-map is the last
> > > such foo-repeat-map defvar appearing in gud.el. In that case, calling M-x
> > > perldb and then running gud-next when repeat-mode is on will bring up the
> > > jdb-repeat-map, which contains some commands that aren't defined for
> > > perldb. So I think the gud-set-repeat-map-property macro (or something like
> > > it) is necessary.
> > 
> > You are right.  Then I have only minor comments:
> > 
> > 1. I thought that you want to create two separate maps for gud-gdb and gdb.
> > This is the reason why I suggested to rename gud-repeat-map to gud-gdb-repeat-map.
> > But since you use only one map for gbd and gud-gdb, then the name
> > gud-repeat-map is fine.
> > 
> > 2. Is there a reason why gud-set-repeat-map-property should be a macro,
> > but not a function?  When it's a macro, there are problems such that
> > when the user modifies the map, then the function that uses the macro
> > needs to be recompiled.
> 
> 
> -- 
> Sent with https://mailfence.com
> Secure and private email
> 
> -- 
> Mailfence.com
> Private and secure email


-- 
Sent with https://mailfence.com
Secure and private email

-- 
Mailfence.com
Private and secure email

[-- Attachment #2: File Attachment: 0001-Ensure-that-gud-commands-for-M-x-gdb-are-handled-by-.patch --]
[-- Type: text/x-diff, Size: 3932 bytes --]

From ed94f68fb2eb675a8f470f811cca838aacea0c59 Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Mon, 19 Jul 2021 23:41:01 -0700
Subject: [PATCH 1/2] 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.
---
 lisp/progmodes/gdb-mi.el |  2 ++
 lisp/progmodes/gud.el    | 37 +++++++++++++++++++++++++------------
 2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 57c99abec6..b9c8305bed 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -996,6 +996,8 @@ gdb
   (define-key gud-minor-mode-map [left-margin C-mouse-3]
     'gdb-mouse-jump)
 
+  (gud-set-repeat-map-property 'gud-gdb-repeat-map)
+
   (setq-local gud-gdb-completion-function 'gud-gdbmi-completions)
 
   (add-hook 'completion-at-point-functions #'gud-gdb-completion-at-point
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 740a6e2581..c4413b104b 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -320,10 +320,32 @@ gud-tool-bar-map
       (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 @@ 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-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)
-- 
2.32.0


[-- Attachment #3: File Attachment: 0002-Ensure-that-gud-commands-for-non-GDB-debuggers-are-h.patch --]
[-- Type: text/x-diff, Size: 9691 bytes --]

From 05b59031397f577589bc7cfe66a6ba5abc2d621c Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@mailfence.com>
Date: Tue, 20 Jul 2021 00:32:34 -0700
Subject: [PATCH 2/2] Ensure that gud commands for non-GDB debuggers are
 handled by repeat-mode

* lisp/progmodes/gud.el (sdb-repeat-map): Define.
(sdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(dbx-repeat-map): Define.
(dbx): Set repeat-mode property to the symbol corresponding to the
repeat map.
(xdb-repeat-map): Define.
(xdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(perldb-repeat-map): Define.
(perldb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(pdb-repeat-map): Define.
(pdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
(guiler-repeat-map): Define.
(guiler): Set repeat-mode property to the symbol corresponding to the
repeat map.
(jdb-repeat-map): Define.
(jdb): Set repeat-mode property to the symbol corresponding to the
repeat map.
---
 lisp/progmodes/gud.el | 110 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index c4413b104b..ba438d651b 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -1037,6 +1037,18 @@ gud-sdb-needs-tags
 
 (defvar gud-sdb-lastfile nil)
 
+(defvar 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'.")
+
 (defun gud-sdb-marker-filter (string)
   (setq gud-marker-acc
 	(if gud-marker-acc (concat gud-marker-acc string) string))
@@ -1107,6 +1119,8 @@ sdb
   (gud-def gud-cont   "c"    "\C-r"   "Continue with display.")
   (gud-def gud-print  "%e/"  "\C-p"   "Evaluate C expression at point.")
 
+  (gud-set-repeat-map-property 'sdb-repeat-map)
+
   (setq comint-prompt-regexp  "\\(^\\|\n\\)\\*")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'sdb-mode-hook)
@@ -1265,6 +1279,23 @@ gud-dbx-use-stopformat-p
 ;; whereby `set $stopformat=1' reportedly produces output compatible
 ;; with `gud-dbx-marker-filter', which we prefer.
 
+(defvar 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'.")
+
 ;; The process filter is also somewhat
 ;; unreliable, sometimes not spotting the markers; I don't know
 ;; whether there's anything that can be done about that.]
@@ -1412,6 +1443,8 @@ dbx
   (gud-def gud-print  "print %e"  "\C-p" "Evaluate C expression at point.")
   (gud-def gud-run    "run"	     nil    "Run the program.")
 
+  (gud-set-repeat-map-property 'dbx-repeat-map)
+
   (setq comint-prompt-regexp  "^[^)\n]*dbx) *")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'dbx-mode-hook)
@@ -1423,6 +1456,21 @@ dbx
 ;; History of argument lists passed to xdb.
 (defvar gud-xdb-history nil)
 
+(defvar 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'.")
+
 (defcustom gud-xdb-directories nil
   "A list of directories that xdb should search for source code.
 If nil, only source files in the program directory
@@ -1488,6 +1536,8 @@ xdb
   (gud-def gud-finish "bu\\t"      "\C-f" "Finish executing current function.")
   (gud-def gud-print  "p %e"       "\C-p" "Evaluate C expression at point.")
 
+  (gud-set-repeat-map-property 'xdb-repeat-map)
+
   (setq comint-prompt-regexp  "^>")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'xdb-mode-hook))
@@ -1498,6 +1548,17 @@ xdb
 ;; History of argument lists passed to perldb.
 (defvar gud-perldb-history nil)
 
+(defvar 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'.")
+
 (defun gud-perldb-massage-args (_file args)
   "Convert a command line as would be typed normally to run perldb
 into one that invokes an Emacs-enabled debugging session.
@@ -1640,6 +1701,7 @@ perldb
   (gud-def gud-print  "p %e"          "\C-p" "Evaluate perl expression at point.")
   (gud-def gud-until  "c %l"          "\C-u" "Continue to current line.")
 
+  (gud-set-repeat-map-property 'perldb-repeat-map)
 
   (setq comint-prompt-regexp "^  DB<+[0-9]+>+ ")
   (setq paragraph-start comint-prompt-regexp)
@@ -1668,6 +1730,20 @@ gud-pdb-marker-regexp-fnname-group
 
 (defvar gud-pdb-marker-regexp-start "^> ")
 
+(defvar 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'.")
+
 ;; There's no guarantee that Emacs will hand the filter the entire
 ;; marker at once; it could be broken up across several strings.  We
 ;; might even receive a big chunk with several markers in it.  If we
@@ -1757,6 +1833,8 @@ pdb
   (gud-def gud-print  "p %e"         "\C-p" "Evaluate Python expression at point.")
   (gud-def gud-statement "!%e"      "\C-e" "Execute Python statement at point.")
 
+  (gud-set-repeat-map-property 'pdb-repeat-map)
+
   ;; (setq comint-prompt-regexp "^(.*pdb[+]?) *")
   (setq comint-prompt-regexp "^(Pdb) *")
   (setq paragraph-start comint-prompt-regexp)
@@ -1770,6 +1848,19 @@ gud-guiler-history
 
 (defvar gud-guiler-lastfile nil)
 
+(defvar 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'.")
+
 (defun gud-guiler-marker-filter (string)
   (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string))
 
@@ -1835,6 +1926,8 @@ guiler
   (gud-def gud-down   ",down"         ">" "Down one stack frame.")
   (gud-def gud-print  "%e"            "\C-p" "Evaluate Guile expression at point.")
 
+  (gud-set-repeat-map-property 'guiler-repeat-map)
+
   (setq comint-prompt-regexp "^scheme@([^>]+> ")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'guiler-mode-hook))
@@ -2280,6 +2373,21 @@ gud-jdb-find-source-file
 ;; Note: Reset to this value every time a prompt is seen
 (defvar gud-jdb-lowest-stack-level 999)
 
+(defvar 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'.")
+
 (defun gud-jdb-find-source-using-classpath (p)
   "Find source file corresponding to fully qualified class P.
 Convert P from jdb's output, converted to a pathname
@@ -2488,6 +2596,8 @@ jdb
   (gud-def gud-print  "print %e"  "\C-p" "Print value of expression at point.")
   (gud-def gud-pstar  "dump %e"  nil "Print all object information at point.")
 
+  (gud-set-repeat-map-property 'jdb-repeat-map)
+
   (setq comint-prompt-regexp "^> \\|^[^ ]+\\[[0-9]+\\] ")
   (setq paragraph-start comint-prompt-regexp)
   (run-hooks 'jdb-mode-hook)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-27  6:46                     ` Brian Leung
@ 2021-07-27 21:15                       ` Juri Linkov
  2021-07-28 11:30                         ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2021-07-27 21:15 UTC (permalink / raw)
  To: Brian Leung; +Cc: Lars Ingebrigtsen, 49632

tags 49632 fixed
close 49632 28.0.50
thanks

> I found a way to make gud-set-repeat-map-property a function without
> having to change repeat.el. See attached for an updated patch.

Thanks, using a symbol is the correct way to implement this indeed.
So now pushed to master.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-27 21:15                       ` Juri Linkov
@ 2021-07-28 11:30                         ` Eli Zaretskii
  2021-07-28 16:23                           ` Juri Linkov
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2021-07-28 11:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: larsi, 49632, leungbk

> From: Juri Linkov <juri@linkov.net>
> Date: Wed, 28 Jul 2021 00:15:46 +0300
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, 49632@debbugs.gnu.org
> 
> > I found a way to make gud-set-repeat-map-property a function without
> > having to change repeat.el. See attached for an updated patch.
> 
> Thanks, using a symbol is the correct way to implement this indeed.
> So now pushed to master.

This causes the following unwanted side-effect:

    GEN      loaddefs.el
  Not registering prefix "gu" from gud.  Affects: ("guiler-repeat-map" "gud-val" "gud-last-frame" "gud-last-last-frame" "gud-last-speedbar-stackframe" "gud-query-cmdline" "gud-xdb-history" "gud-xdb-directories" "gud-xdb-massage-args" "gud-xdb-marker-filter" "gud-goto-info" "gud-gdb-history" "gud-gdb-marker-regexp" "gud-gdb-marker-filter" "gud-gdb-completions" "gud-gdb-completions-1" "gud-gdb-completion-function" "gud-gdb-completion-at-point" "gud-gdb-fetch-lines-filter" "gud-gdb-fetched-stack-frame" "gud-gdb-goto-stackframe" "gud-gdb-get-stackframe" "gud-gdb-repeat-map" "gud-gdb-run-command-fetch-lines" "gud-gud-gdb-command-name" "gud-guiler-history" "gud-guiler-lastfile" "gud-guiler-marker-filter" "gud-guiler-command-name" "gud-jdb-use-classpath" "gud-jdb-history" "gud-jdb-directories" "g
 ud-jdb-sourcepath" "gud-jdb-source-files" "gud-jdb-skip-traditional-or-documentation-comment" "gud-jdb-skip-whitespace" "gud-jdb-skip-whitespace-and-comments" "gud-jdb-skip-id-ish-thing" "gud-jdb-skip-single-line-comment" "gud-jdb-skip-string-literal" "gud-jdb-skip-character-literal" "gud-jdb-skip-block" "gud-jdb-analysis-buffer" "gud-jdb-analyze-source" "gud-jdb-build-source-files-list" "gud-jdb-build-class-source-alist" "gud-jdb-build-class-source-alist-for-file" "gud-jdb-lowest-stack-level" "gud-jdb-find-source" "gud-jdb-find-source-file" "gud-jdb-find-source-using-classpath" "gud-jdb-parse-classpath-string" "gud-jdb-massage-args" "gud-jdb-marker-filter" "gud-jdb-class-source-alist" "gud-jdb-classpath" "gud-jdb-classpath-string" "gud-jdb-command-name" "gud-marker-filter" "gud-marker-a
 cc" "gud-marker-acc-max-length" "gud-mode" "gud-mode-map" "gud-mips-p" "gud-mipsdbx-marker-filter" "gud-minor-mode" "gud-minor-mode-type" "gud-overlay-arrow-position" "gud-symbol" "gud-stop-subjob" "gud-speedbar-key-map" "gud-speedbar-item-info" "gud-speedbar-menu-items" "gud-speedbar-buttons" "gud-sdb-history" "gud-sdb-needs-tags" "gud-sdb-lastfile" "gud-sdb-marker-filter" "gud-sdb-find-file" "gud-set-repeat-map-property" "gud-set-buffer" "gud-sentinel" "gud-key-prefix" "gud-keep-buffer" "gud-kill-buffer-hook" "gud-dbx-history" "gud-dbx-directories" "gud-dbx-massage-args" "gud-dbx-marker-filter" "gud-dbx-command-name" "gud-dbx-use-stopformat-p" "gud-dguxdbx-marker-filter" "gud-def" "gud-delete-prompt-marker" "gud-display-frame" "gud-display-line" "gud-chdir-before-run" "gud-comint-buffe
 r" "gud-common-init" "gud-call" "gud-running" "gud-reset" "gud-read-address" "gud-refresh" "gud-irix-p" "gud-irixdbx-marker-filter" "gud-install-speedbar-variables" "gud-innermost-expr" "gud-basic-call" "gud-backward-sexp" "gud-perldb-history" "gud-perldb-massage-args" "gud-perldb-marker-filter" "gud-perldb-command-name" "gud-pdb-history" "gud-pdb-marker-regexp" "gud-pdb-marker-regexp-line-group" "gud-pdb-marker-regexp-file-group" "gud-pdb-marker-regexp-fnname-group" "gud-pdb-marker-regexp-start" "gud-pdb-marker-filter" "gud-pdb-command-name" "gud-prev-expr" "gud-next-expr" "gud-expansion-speedbar-buttons" "gud-expr-compound" "gud-expr-compound-sep" "gud-format-command" "gud-forward-sexp" "gud-file-name" "gud-filter" "gud-filter-pending-text" "gud-filter-defer-flag" "gud-find-file" "gud-
 find-expr" "gud-find-expr-function" "gud-find-c-expr" "gud-find-class" "gud-target-name" "gud-tool-bar-item-visible-no-fringe" "gud-tool-bar-map" "gud-tooltip-change-major-mode" "gud-tooltip-activate-mouse-motions" "gud-tooltip-activate-mouse-motions-if-enabled" "gud-tooltip-modes" "gud-tooltip-mouse-motion" "gud-tooltip-mouse-motions-active" "gud-tooltip-echo-area" "gud-tooltip-event" "gud-tooltip-display" "gud-tooltip-dereference" "gud-tooltip-process-output" "gud-tooltip-print-command" "gud-tooltip-tips")

Can we please avoid this regression?

Thanks.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-28 11:30                         ` Eli Zaretskii
@ 2021-07-28 16:23                           ` Juri Linkov
  2021-07-28 16:30                             ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2021-07-28 16:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: larsi, 49632, leungbk

> This causes the following unwanted side-effect:
>
>     GEN      loaddefs.el
>   Not registering prefix "gu" from gud.  Affects: ("guiler-repeat-map" "gud-val" "gud-last-frame" "gud-last-last-frame" "gud-last-speedbar-stackframe" "gud-query-cmdline" "gud-xdb-history" "gud-xdb-directories" "gud-xdb-massage-args" "gud-xdb-marker-filter" "gud-goto-info" "gud-gdb-history" "gud-gdb-marker-regexp" "gud-gdb-marker-filter" "gud-gdb-completions" "gud-gdb-completions-1" "gud-gdb-completion-function" "gud-gdb-completion-at-point" "gud-gdb-fetch-lines-filter" "gud-gdb-fetched-stack-frame" "gud-gdb-goto-stackframe" "gud-gdb-get-stackframe" "gud-gdb-repeat-map" "gud-gdb-run-command-fetch-lines" "gud-gud-gdb-command-name" "gud-guiler-history" "gud-guiler-lastfile" "gud-guiler-marker-filter" "gud-guiler-command-name" "gud-jdb-use-classpath" "gud-jdb-history" "gud-jdb-directories" 
 "gud-jdb-sourcepath" "gud-jdb-source-files" "gud-jdb-skip-traditional-or-documentation-comment" "gud-jdb-skip-whitespace" "gud-jdb-skip-whitespace-and-comments" "gud-jdb-skip-id-ish-thing" "gud-jdb-
 sk
>  ip-single-line-comment" "gud-jdb-skip-string-literal" "gud-jdb-skip-character-literal" "gud-jdb-skip-block" "gud-jdb-analysis-buffer" "gud-jdb-analyze-source" "gud-jdb-build-source-files-list" "gud-jdb-build-class-source-alist" "gud-jdb-build-class-source-alist-for-file" "gud-jdb-lowest-stack-level" "gud-jdb-find-source" "gud-jdb-find-source-file" "gud-jdb-find-source-using-classpath" "gud-jdb-parse-classpath-string" "gud-jdb-massage-args" "gud-jdb-marker-filter" "gud-jdb-class-source-alist" "gud-jdb-classpath" "gud-jdb-classpath-string" "gud-jdb-command-name" "gud-marker-filter" "gud-marker-acc" "gud-marker-acc-max-length" "gud-mode" "gud-mode-map" "gud-mips-p" "gud-mipsdbx-marker-filter" "gud-minor-mode" "gud-minor-mode-type" "gud-overlay-arrow-position" "gud-symbol" "gud-stop-subjob"
  "gud-speedbar-key-map" "gud-speedbar-item-info" "gud-speedbar-menu-items" "gud-speedbar-buttons" "gud-sdb-history" "gud-sdb-needs-tags" "gud-sdb-lastfile" "gud-sdb-marker-filter" "gud-sdb-find-file
 " 
>  "gud-set-repeat-map-property" "gud-set-buffer" "gud-sentinel" "gud-key-prefix" "gud-keep-buffer" "gud-kill-buffer-hook" "gud-dbx-history" "gud-dbx-directories" "gud-dbx-massage-args" "gud-dbx-marker-filter" "gud-dbx-command-name" "gud-dbx-use-stopformat-p" "gud-dguxdbx-marker-filter" "gud-def" "gud-delete-prompt-marker" "gud-display-frame" "gud-display-line" "gud-chdir-before-run" "gud-comint-buffer" "gud-common-init" "gud-call" "gud-running" "gud-reset" "gud-read-address" "gud-refresh" "gud-irix-p" "gud-irixdbx-marker-filter" "gud-install-speedbar-variables" "gud-innermost-expr" "gud-basic-call" "gud-backward-sexp" "gud-perldb-history" "gud-perldb-massage-args" "gud-perldb-marker-filter" "gud-perldb-command-name" "gud-pdb-history" "gud-pdb-marker-regexp" "gud-pdb-marker-regexp-line-gro
 up" "gud-pdb-marker-regexp-file-group" "gud-pdb-marker-regexp-fnname-group" "gud-pdb-marker-regexp-start" "gud-pdb-marker-filter" "gud-pdb-command-name" "gud-prev-expr" "gud-next-expr" "gud-expansio
 n-
>  speedbar-buttons" "gud-expr-compound" "gud-expr-compound-sep" "gud-format-command" "gud-forward-sexp" "gud-file-name" "gud-filter" "gud-filter-pending-text" "gud-filter-defer-flag" "gud-find-file" "gud-find-expr" "gud-find-expr-function" "gud-find-c-expr" "gud-find-class" "gud-target-name" "gud-tool-bar-item-visible-no-fringe" "gud-tool-bar-map" "gud-tooltip-change-major-mode" "gud-tooltip-activate-mouse-motions" "gud-tooltip-activate-mouse-motions-if-enabled" "gud-tooltip-modes" "gud-tooltip-mouse-motion" "gud-tooltip-mouse-motions-active" "gud-tooltip-echo-area" "gud-tooltip-event" "gud-tooltip-display" "gud-tooltip-dereference" "gud-tooltip-process-output" "gud-tooltip-print-command" "gud-tooltip-tips")
>
> Can we please avoid this regression?

I haven't noticed this warning because it's not highlighted with the
warning face.  Now fixed.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map
  2021-07-28 16:23                           ` Juri Linkov
@ 2021-07-28 16:30                             ` Eli Zaretskii
  0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2021-07-28 16:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: larsi, 49632, leungbk

> From: Juri Linkov <juri@linkov.net>
> Cc: leungbk@mailfence.com,  larsi@gnus.org,  49632@debbugs.gnu.org
> Date: Wed, 28 Jul 2021 19:23:27 +0300
> 
> > Can we please avoid this regression?
> 
> I haven't noticed this warning because it's not highlighted with the
> warning face.  Now fixed.

Thanks.





^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-07-28 16:30 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19  3:37 bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map Brian Leung
2021-07-19 13:06 ` Lars Ingebrigtsen
2021-07-19 13:13   ` Eli Zaretskii
2021-07-19 14:57     ` Brian Leung
2021-07-19 16:05       ` Eli Zaretskii
2021-07-19 21:53         ` Juri Linkov
2021-07-19 14:51   ` Brian Leung via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-19 15:37     ` Juri Linkov
2021-07-19 15:52       ` Lars Ingebrigtsen
2021-07-24  3:33         ` Brian Leung
2021-07-25  6:26           ` Lars Ingebrigtsen
2021-07-25 20:53             ` Juri Linkov
2021-07-25 21:28               ` Brian Leung
2021-07-26 22:48                 ` Juri Linkov
2021-07-27  4:09                   ` Brian Leung
2021-07-27  6:46                     ` Brian Leung
2021-07-27 21:15                       ` Juri Linkov
2021-07-28 11:30                         ` Eli Zaretskii
2021-07-28 16:23                           ` Juri Linkov
2021-07-28 16:30                             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).