From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Brian Leung Newsgroups: gmane.emacs.bugs Subject: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-map Date: Sat, 24 Jul 2021 05:33:50 +0200 (CEST) Message-ID: <2097190220.304800.1627097630028@ichabod.co-bxl> References: <89178870.2006793.1626665845848@ichabod.co-bxl> <87eebupi5k.fsf@gnus.org> <343742107.2068902.1626706305280@ichabod.co-bxl> <87k0lml3wt.fsf@mail.linkov.net> <874kcql2r8.fsf@gnus.org> Reply-To: Brian Leung Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_304747_1485939163.1627097577379" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13699"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49632@debbugs.gnu.org To: Juri Linkov , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 24 05:35:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m78RT-0003L9-Lo for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Jul 2021 05:35:11 +0200 Original-Received: from localhost ([::1]:46954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m78RR-0002sa-Uh for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Jul 2021 23:35:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m78RK-0002sS-3Y for bug-gnu-emacs@gnu.org; Fri, 23 Jul 2021 23:35:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m78RJ-0004DD-So for bug-gnu-emacs@gnu.org; Fri, 23 Jul 2021 23:35:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m78RJ-00059L-Kk for bug-gnu-emacs@gnu.org; Fri, 23 Jul 2021 23:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Brian Leung Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Jul 2021 03:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49632 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49632-submit@debbugs.gnu.org id=B49632.162709764819730 (code B ref 49632); Sat, 24 Jul 2021 03:35:01 +0000 Original-Received: (at 49632) by debbugs.gnu.org; 24 Jul 2021 03:34:08 +0000 Original-Received: from localhost ([127.0.0.1]:44984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m78QR-000589-A8 for submit@debbugs.gnu.org; Fri, 23 Jul 2021 23:34:08 -0400 Original-Received: from wilbur.contactoffice.com ([212.3.242.68]:58810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m78QL-00057a-FV for 49632@debbugs.gnu.org; Fri, 23 Jul 2021 23:34:05 -0400 Original-Received: from ichabod.co-bxl (ichabod.co-bxl [10.2.0.36]) by wilbur.contactoffice.com (Postfix) with ESMTP id C6FCD9CA; Sat, 24 Jul 2021 05:33:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1627097633; s=20210208-e7xh; d=mailfence.com; i=leungbk@mailfence.com; h=Date:From:Reply-To:Cc:Message-ID:In-Reply-To:References:MIME-Version:Content-Type; l=13901; bh=xhOohRdIcS+XppNJsU9uaJ03brnr46+RIHwSGTCTG1I=; b=aQqd1DGAQ6155LUltFpMvk96v+HBehb9axX4YUZmmkGVLz7jrqYrXk7vJecQZx99 h4IflLUIVRnVjldBMd24HKziiTTxoTDNYS3V0FakM1nsR0gJzEWSt1iDAf/Ny9p8ry1 IrYnuqMdFqx2MpMOuTEdL/B10xD/PZOlpYiRPrDJWejCWGTQUVwdIWDeOuhJfYTLEx0 aJjbIj2G6gcLnyuIIYeMTK6vvv14tbpGYmTdDyj3fGoFKFsEy41Xf1r1hkxjh+vXL8d FhUI9c72K1Dk16D+JHJShqbixz46OXxMx0lNynfCniJxldhzc59EynC2VAMhlrfHwUZ 863bm4P8Sw== In-Reply-To: <874kcql2r8.fsf@gnus.org> X-Priority: 3 X-Mailer: ContactOffice Mail X-ContactOffice-Account: com:225491745 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:210620 Archived-At: ------=_Part_304747_1485939163.1627097577379 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable OK, I've updated the patch following Juri's suggestions. > ---------------------------------------- > From: Lars Ingebrigtsen > Sent: Mon Jul 19 17:52:43 CEST 2021 > To: Juri Linkov > Cc: Brian Leung , <49632@debbugs.gnu.org> > Subject: Re: bug#49632: [PATCH] Ensure that M-x gdb populates gud-repeat-= map >=20 >=20 > Juri Linkov writes: >=20 > > 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-map= s > > named e.g. 'sdb-repeat-map', 'jdb-repeat-map', 'perldb-repeat-map', etc= . >=20 > 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. >=20 > --=20 > (domestic pets only, the antidote for overdose, milk.) > bloggy blog: http://lars.ingebrigtsen.no --=C2=A0 Sent with https://mailfence.com Secure and private email --=20 Mailfence.com Private and secure email ------=_Part_304747_1485939163.1627097577379 Content-Type: text/x-diff; charset=us-ascii; name=0001-Ensure-that-gud-commands-for-M-x-gdb-are-handled-by-.patch Content-Transfer-Encoding: 7bit Content-Description: File Attachment: 0001-Ensure-that-gud-commands-for-M-x-gdb-are-handled-by-.patch Content-Disposition: attachment; filename=0001-Ensure-that-gud-commands-for-M-x-gdb-are-handled-by-.patch >From 14d770b2f1df8ec9cdb7b1ef60e7870b3e3f849d Mon Sep 17 00:00:00 2001 From: Brian Leung 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--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 ------=_Part_304747_1485939163.1627097577379 Content-Type: text/x-diff; charset=us-ascii; name=0002-Ensure-that-gud-commands-for-non-GDB-debuggers-are-h.patch Content-Transfer-Encoding: 7bit Content-Description: File Attachment: 0002-Ensure-that-gud-commands-for-non-GDB-debuggers-are-h.patch Content-Disposition: attachment; filename=0002-Ensure-that-gud-commands-for-non-GDB-debuggers-are-h.patch >From fa6428ff8995b864c8b65aa218d1085372bd3994 Mon Sep 17 00:00:00 2001 From: Brian Leung 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 ------=_Part_304747_1485939163.1627097577379--