ftp://ftp.xemacs.org/pub/xemacs/contrib/gud.el is Steve's XEmacs
port of gud.el from Emacs 20.3.
Here is patch against it fixing one bug, adding easymenu and making
it work both in XEmacs and Emacs. RMS might accept easymenu change
to Emacs' gud.el too, but I haven't sent this patch yet to RMS, as
I want to hear your comments first.
Adrian please test this on windows. Original Emacs-20.3 gud.el had
a comment about path-regexp fixed for windows paths, so this might
work without your patch.
This has been sent both to beta and patches list.
1998-12-14 Aki Vehtari <Aki.Vehtari(a)hut.fi>
* gud.el: (gud-format-command): In concat use int-to-string
(gud-new-keymap): Make this work in XEmacs and Emacs
(gud-make-debug-menu): Use easymenu
--- gud.el.orig Fri Dec 11 13:20:33 1998
+++ gud.el Mon Dec 14 16:59:22 1998
@@ -75,22 +75,6 @@
(setq file (replace-match "/" t t file)))
(funcall gud-find-file file))
-;; Keymap definitions for menu bar entries common to all debuggers and
-;; slots for debugger-dependent ones in sensible places. (Defined here
-;; before use.)
-(defvar gud-menu-map (make-sparse-keymap "Gud"))
-(define-key gud-menu-map [refresh] '("Refresh" . gud-refresh))
-(define-key gud-menu-map [remove] '("Remove Breakpoint" . gud-remove))
-(define-key gud-menu-map [tbreak] nil) ; gdb, sdb and xdb
-(define-key gud-menu-map [break] '("Set Breakpoint" . gud-break))
-(define-key gud-menu-map [up] nil) ; gdb, dbx, and xdb
-(define-key gud-menu-map [down] nil) ; gdb, dbx, and xdb
-(define-key gud-menu-map [print] '("Print Expression" . gud-print))
-(define-key gud-menu-map [finish] nil) ; gdb or xdb
-(define-key gud-menu-map [stepi] '("Step Instruction" . gud-stepi))
-(define-key gud-menu-map [step] '("Step Line" . gud-step))
-(define-key gud-menu-map [next] '("Next Line" . gud-next))
-(define-key gud-menu-map [cont] '("Continue" . gud-cont))
;; ======================================================================
;; command definition
@@ -329,11 +313,14 @@
(let ((buf (find-file-noselect f)))
(set-buffer buf)
(gud-make-debug-menu)
- (local-set-key [menu-bar debug tbreak]
- '("Temporary Breakpoint" . gud-tbreak))
- (local-set-key [menu-bar debug finish] '("Finish Function" .
gud-finish))
- (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ (easy-menu-add-item
+ nil '("Gud") '["Temporary Breakpoint" gud-tbreak t]
"Remove Breakpoint")
+ (easy-menu-add-item
+ nil '("Gud") '["Finish Function" gud-finish t]
"-")
+ (easy-menu-add-item
+ nil '("Gud") '["Down Stack" gud-down t]
"--")
+ (easy-menu-add-item
+ nil '("Gud") '["Up Stack" gud-up t] "--")
buf)))
(defvar gdb-minibuffer-local-map nil
@@ -373,10 +360,14 @@
(gud-def gud-print "print %e" "\C-p" "Evaluate C
expression at point.")
(local-set-key "\C-i" 'gud-gdb-complete-command)
- (local-set-key [menu-bar debug tbreak] '("Temporary Breakpoint" .
gud-tbreak))
- (local-set-key [menu-bar debug finish] '("Finish Function" .
gud-finish))
- (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ (easy-menu-add-item
+ nil '("Gud") '["Temporary Breakpoint" gud-tbreak t]
"Remove Breakpoint")
+ (easy-menu-add-item
+ nil '("Gud") '["Finish Function" gud-finish t]
"-")
+ (easy-menu-add-item
+ nil '("Gud") '["Down Stack" gud-down t] "--")
+ (easy-menu-add-item
+ nil '("Gud") '["Up Stack" gud-up t] "--")
(setq comint-prompt-regexp "^(.*gdb[+]?) *")
(setq paragraph-start comint-prompt-regexp)
(run-hooks 'gdb-mode-hook)
@@ -651,7 +642,8 @@
(find-file-noselect f))))
(set-buffer buf)
(gud-make-debug-menu)
- (local-set-key [menu-bar debug tbreak] '("Temporary Breakpoint" .
gud-tbreak))
+ (easy-menu-add-item
+ nil '("Gud") '["Temporary Breakpoint" gud-tbreak t]
"Remove Breakpoint")
buf)))
;;;###autoload
@@ -686,8 +678,8 @@
(setq comint-prompt-regexp "\\(^\\|\n\\)\\*")
(setq paragraph-start comint-prompt-regexp)
- (local-set-key [menu-bar debug tbreak]
- '("Temporary Breakpoint" . gud-tbreak))
+ (easy-menu-add-item
+ nil '("Gud") '["Temporary Breakpoint" gud-tbreak t]
"Remove Breakpoint")
(run-hooks 'sdb-mode-hook)
)
@@ -983,8 +975,10 @@
(let ((buf (find-file-noselect realf)))
(set-buffer buf)
(gud-make-debug-menu)
- (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ (easy-menu-add-item
+ nil '("Gud") '["Down Stack" gud-down t]
"--")
+ (easy-menu-add-item
+ nil '("Gud") '["Up Stack" gud-up t] "--")
buf)
nil))))
@@ -1051,8 +1045,10 @@
(setq comint-prompt-regexp "^[^)\n]*dbx) *")
(setq paragraph-start comint-prompt-regexp)
- (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ (easy-menu-add-item
+ nil '("Gud") '["Down Stack" gud-down t] "--")
+ (easy-menu-add-item
+ nil '("Gud") '["Up Stack" gud-up t] "--")
(run-hooks 'dbx-mode-hook)
)
@@ -1125,12 +1121,14 @@
(let ((buf (find-file-noselect realf)))
(set-buffer buf)
(gud-make-debug-menu)
- (local-set-key [menu-bar debug tbreak]
- '("Temporary Breakpoint" . gud-tbreak))
- (local-set-key [menu-bar debug finish]
- '("Finish Function" . gud-finish))
- (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ (easy-menu-add-item
+ nil '("Gud") '["Temporary Breakpoint" gud-tbreak t]
"Remove Breakpoint")
+ (easy-menu-add-item
+ nil '("Gud") '["Finish Function" gud-finish t]
"-")
+ (easy-menu-add-item
+ nil '("Gud") '["Down Stack" gud-down t]
"--")
+ (easy-menu-add-item
+ nil '("Gud") '["Up Stack" gud-up t] "--")
buf)
nil))))
@@ -1167,10 +1165,14 @@
(setq comint-prompt-regexp "^>")
(setq paragraph-start comint-prompt-regexp)
- (local-set-key [menu-bar debug tbreak] '("Temporary Breakpoint" .
gud-tbreak))
- (local-set-key [menu-bar debug finish] '("Finish Function" .
gud-finish))
- (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ (easy-menu-add-item
+ nil '("Gud") '["Temporary Breakpoint" gud-tbreak t]
"Remove Breakpoint")
+ (easy-menu-add-item
+ nil '("Gud") '["Finish Function" gud-finish t]
"-")
+ (easy-menu-add-item
+ nil '("Gud") '["Down Stack" gud-down t] "--")
+ (easy-menu-add-item
+ nil '("Gud") '["Up Stack" gud-up t] "--")
(run-hooks 'xdb-mode-hook))
;; ======================================================================
@@ -1364,9 +1366,12 @@
(let ((buf (find-file-noselect f)))
(set-buffer buf)
(gud-make-debug-menu)
- ;; (local-set-key [menu-bar debug finish] '("Finish Function" .
gud-finish))
- ;; (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- ;; (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ ;;(easy-menu-add-item
+ ;; nil '("Gud") '["Finish Function" gud-finish t]
"-")
+ ;;(easy-menu-add-item
+ ;; nil '("Gud") '["Down Stack" gud-down t]
"--")
+ ;;(easy-menu-add-item
+ ;; nil '("Gud") '["Up Stack" gud-up t] "--")
buf)))
(defvar pdb-minibuffer-local-map nil
@@ -1411,9 +1416,12 @@
;; Is this right?
(gud-def gud-statement "! %e" "\C-e" "Execute Python
statement at point.")
- (local-set-key [menu-bar debug finish] '("Finish Function" .
gud-finish))
- (local-set-key [menu-bar debug up] '("Up Stack" . gud-up))
- (local-set-key [menu-bar debug down] '("Down Stack" . gud-down))
+ (easy-menu-add-item
+ nil '("Gud") '["Finish Function" gud-finish t]
"-")
+ (easy-menu-add-item
+ nil '("Gud") '["Down Stack" gud-down t] "--")
+ (easy-menu-add-item
+ nil '("Gud") '["Up Stack" gud-up t] "--")
;; (setq comint-prompt-regexp "^(.*pdb[+]?) *")
(setq comint-prompt-regexp "^(Pdb) *")
(setq paragraph-start comint-prompt-regexp)
@@ -2277,12 +2285,13 @@
(buffer-file-name)
(car frame)))))
((eq key ?l)
- (setq subst (if insource
+ (setq subst (int-to-string
+ (if insource
(save-excursion
(beginning-of-line)
(save-restriction (widen)
(1+ (count-lines 1 (point)))))
- (cdr frame))))
+ (cdr frame)))))
((eq key ?e)
(setq subst (gud-find-c-expr)))
((eq key ?a)
@@ -2350,9 +2359,8 @@
; (nconc (make-sparse-keymap "Gud") map))
(defun gud-new-keymap (map)
"Return a new keymap which inherits from MAP and has name `Gud'."
- (let ((new-map (make-sparse-keymap)))
- (set-keymap-parents new-map map)
- (set-keymap-name new-map "Gud")
+ (let ((new-map (make-sparse-keymap "Gud")))
+ (set-keymap-parent new-map map)
new-map))
;(defun gud-make-debug-menu ()
@@ -2366,8 +2374,30 @@
; (define-key (current-local-map) [menu-bar debug]
; (cons "Gud" (gud-new-keymap gud-menu-map)))))
(defun gud-make-debug-menu ()
- (unless (string= (keymap-name (current-local-map)) "Gud")
- (use-local-map (gud-new-keymap (current-local-map)))))
+ "Make sure the current menubar has a Gud submenu.
+If it doesn't define it."
+ (if (easy-menu-item-present-p nil nil "Gud")
+ nil
+ (use-local-map (gud-new-keymap (current-local-map)))
+ (easy-menu-define
+ gud-debug-menu
+ (current-local-map)
+ "Gud Menu"
+ '("Gud"
+ ["Continue" gud-cont t]
+ ["Next Line" gud-next t]
+ ["Step Line" gud-step t]
+ ["Step Instruction" gud-stepi t]
+ "-"
+ ["Print Expression" gud-print t]
+ "--"
+ ["Set Breakpoint" gud-break t]
+ ["Remove Breakpoint" gud-remove t]
+ "---"
+ ["Refresh" gud-refresh t]
+ ))
+ (easy-menu-add gud-debug-menu (current-local-map))
+ ))
;;; Code for parsing expressions out of C code. The single entry point is
;;; find-c-expr, which tries to return an lvalue expression from around point.