changeset 58485:31d7630f91d4

(gdb-breakpoints-mode-map) (gdb-frames-mode-map, gdb-threads-mode-map) (gdb-registers-mode-map, gdb-locals-mode-map) (gdb-assembler-mode-map): Bind "q" to kill-this-buffer. (dedicated-switch-to-buffer): Rename to gdb-set-window-buffer. (dedicated-switch-to-buffer): Rework. (gdb-var-evaluate-expression-handler, gdb-put-string): Remove unused variable bindings. (gdb-setup-windows, gdb-display-buffer): Simplify. Use pop-to-buffer. (gdb-view-source-function): Simplify. (gdb-frame-breakpoints-buffer): Use pop-to-buffer, special-display-regexps.
author Nick Roberts <nickrob@snap.net.nz>
date Thu, 25 Nov 2004 02:00:53 +0000
parents abf597230baf
children f9f5c9ddd813
files lisp/progmodes/gdb-ui.el
diffstat 1 files changed, 41 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/gdb-ui.el	Thu Nov 25 01:57:42 2004 +0000
+++ b/lisp/progmodes/gdb-ui.el	Thu Nov 25 02:00:53 2004 +0000
@@ -317,7 +317,7 @@
     (goto-char (point-min))
     (re-search-forward ".*value=\"\\(.*?\\)\"" nil t)
     (catch 'var-found
-      (let ((var-list nil) (num 0))
+      (let ((num 0))
 	(dolist (var gdb-var-list)
 	  (if (string-equal varnum (cadr var))
 	      (progn
@@ -1123,7 +1123,7 @@
 
 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
 (defun gdb-info-breakpoints-custom ()
-  (let ((flag)(address))
+  (let ((flag))
     ;;
     ;; remove all breakpoint-icons in source buffers but not assembler buffer
     (dolist (buffer (buffer-list))
@@ -1199,9 +1199,8 @@
 (defun gdb-frame-breakpoints-buffer ()
   "Display status of user-settable breakpoints in a new frame."
   (interactive)
-  (select-frame (make-frame gdb-frame-parameters))
-  (switch-to-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer))
-  (set-window-dedicated-p (selected-window) t))
+  (let ((special-display-regexps (append special-display-regexps '(".*"))))
+    (pop-to-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer))))
 
 (defvar gdb-breakpoints-mode-map
   (let ((map (make-sparse-keymap))
@@ -1214,6 +1213,7 @@
     (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu))
     (define-key map " " 'gdb-toggle-breakpoint)
     (define-key map "d" 'gdb-delete-breakpoint)
+    (define-key map "q" 'kill-this-buffer)
     (define-key map "\r" 'gdb-goto-breakpoint)
     (define-key map [mouse-2] 'gdb-mouse-goto-breakpoint)
     map))
@@ -1342,6 +1342,7 @@
 (defvar gdb-frames-mode-map
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map)
+    (define-key map "q" 'kill-this-buffer)
     (define-key map "\r" 'gdb-frames-select)
     (define-key map [mouse-2] 'gdb-frames-mouse-select)
     map))
@@ -1423,6 +1424,7 @@
 (defvar gdb-threads-mode-map
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map)
+    (define-key map "q" 'kill-this-buffer)
     (define-key map "\r" 'gdb-threads-select)
     (define-key map [mouse-2] 'gdb-threads-mouse-select)
     map))
@@ -1475,7 +1477,8 @@
 (defvar gdb-registers-mode-map
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map)
-    map))
+    (define-key map "q" 'kill-this-buffer)
+     map))
 
 (defun gdb-registers-mode ()
   "Major mode for gdb registers.
@@ -1551,7 +1554,8 @@
 (defvar gdb-locals-mode-map
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map)
-    map))
+    (define-key map "q" 'kill-this-buffer)
+     map))
 
 (defun gdb-locals-mode ()
   "Major mode for gdb locals.
@@ -1587,16 +1591,18 @@
 
 ;;;; Window management
 (defun gdb-display-buffer (buf &optional size)
-  (let ((must-split nil)
-	(answer nil))
-    (setq answer (get-buffer-window buf 'visible))
-    (if (not answer)
+  (let ((answer (get-buffer-window buf 0))
+	(must-split nil))
+    (if answer
+	(display-buffer answer)		;Raise the frame if necessary.
+      ;; The buffer is not yet displayed.
+      (pop-to-buffer gud-comint-buffer)	;Select the right frame.
 	(let ((window (get-lru-window)))
 	  (if window
 	      (progn
 		(set-window-buffer window buf)
 		(setq answer window))
-	    (setq must-split t))))
+	  (setq must-split t)))
     (if must-split
 	(let* ((largest (get-largest-window))
 	       (cur-size (window-height largest))
@@ -1604,7 +1610,7 @@
 	  (setq answer (split-window largest new-size))
 	  (set-window-buffer answer buf)))
     (set-window-dedicated-p answer t)
-    answer))
+      answer)))
 
 (defun gdb-display-source-buffer (buffer)
   (if (eq gdb-selected-view 'source)
@@ -1680,9 +1686,9 @@
   (interactive)
   (if gdb-view-source
       (gdb-display-buffer
-       (if gud-last-last-frame
-	   (gud-find-file (car gud-last-last-frame))
-	 (gud-find-file gdb-main-file))))
+       (gud-find-file (if gud-last-last-frame
+			  (car gud-last-last-frame)
+			gdb-main-file))))
   (setq gdb-selected-view 'source))
 
 (defun gdb-view-assembler()
@@ -1702,10 +1708,9 @@
   :group 'gud
   :version "21.4")
 
-(defun dedicated-switch-to-buffer (name)
-  (set-window-dedicated-p 
-   (get-buffer-window
-    (switch-to-buffer name)) t))
+(defun gdb-set-window-buffer (name)
+  (set-window-buffer (selected-window) (get-buffer name))
+  (set-window-dedicated-p (selected-window) t))
 
 (defun gdb-setup-windows ()
   "Layout the window pattern for gdb-many-windows."
@@ -1714,14 +1719,14 @@
   (delete-other-windows)
   (gdb-display-breakpoints-buffer)
   (delete-other-windows)
-  (dedicated-switch-to-buffer gud-comint-buffer)
+  (gdb-set-window-buffer gud-comint-buffer)
   (split-window nil ( / ( * (window-height) 3) 4))
   (split-window nil ( / (window-height) 3))
   (split-window-horizontally)
   (other-window 1)
-  (dedicated-switch-to-buffer (gdb-locals-buffer-name))
+  (gdb-set-window-buffer (gdb-locals-buffer-name))
   (other-window 1)
-  (dedicated-switch-to-buffer
+  (gdb-set-window-buffer
    (if (and gdb-view-source
 	    (eq gdb-selected-view 'source))
        (if gud-last-last-frame
@@ -1731,12 +1736,12 @@
   (when gdb-use-inferior-io-buffer
     (split-window-horizontally)
     (other-window 1)
-    (dedicated-switch-to-buffer (gdb-inferior-io-name)))
+    (gdb-set-window-buffer (gdb-inferior-io-name)))
   (other-window 1)
-  (dedicated-switch-to-buffer (gdb-stack-buffer-name))
+  (gdb-set-window-buffer (gdb-stack-buffer-name))
   (split-window-horizontally)
   (other-window 1)
-  (dedicated-switch-to-buffer (gdb-breakpoints-buffer-name))
+  (gdb-set-window-buffer (gdb-breakpoints-buffer-name))
   (other-window 1))
 
 (defcustom gdb-many-windows nil
@@ -1764,16 +1769,13 @@
   "Restore the basic arrangement of windows used by gdba.
 This arrangement depends on the value of `gdb-many-windows'."
   (interactive)
+  (pop-to-buffer gud-comint-buffer)	;Select the right window and frame.
+    (delete-other-windows)
   (if gdb-many-windows
-      (progn
-	(switch-to-buffer gud-comint-buffer)
-	(delete-other-windows)
-	(gdb-setup-windows))
-    (switch-to-buffer gud-comint-buffer)
-    (delete-other-windows)
+      (gdb-setup-windows)
     (split-window)
     (other-window 1)
-    (dedicated-switch-to-buffer
+    (gdb-set-window-buffer
      (if (and gdb-view-source
 	      (eq gdb-selected-view 'source))
 	 (if gud-last-last-frame
@@ -1819,15 +1821,11 @@
       (gdb-setup-windows)
     (gdb-get-create-buffer 'gdb-breakpoints-buffer)
     (when gdb-show-main
-      (switch-to-buffer gud-comint-buffer)
-      (delete-other-windows)
-      (split-window)
-      (other-window 1)
-      (switch-to-buffer
+      (let ((pop-up-windows t))
+	(display-buffer
        (if gdb-view-source
 	   (gud-find-file gdb-main-file)
-	 (gdb-get-create-buffer 'gdb-assembler-buffer)))
-      (other-window 1))))
+	   (gdb-get-create-buffer 'gdb-assembler-buffer)))))))
 
 ;;from put-image
 (defun gdb-put-string (putstring pos &optional dprop)
@@ -1971,7 +1969,8 @@
 (defvar gdb-assembler-mode-map
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map)
-    map))
+    (define-key map "q" 'kill-this-buffer)
+     map))
 
 (defvar gdb-assembler-font-lock-keywords
   '(;; <__function.name+n>
@@ -2037,7 +2036,7 @@
 	  (progn
 	    ;; take previous disassemble command off the queue
 	    (with-current-buffer gud-comint-buffer
-	      (let ((queue gdb-input-queue) (item))
+	      (let ((queue gdb-input-queue))
 		(dolist (item queue)
 		  (if (equal (cdr item) '(gdb-assembler-handler))
 		      (setq gdb-input-queue