changeset 65953:0f60854c0845

(gud-last-speedbar-buffer): Remove. (gud-install-speedbar-variables): Add GUD to speedbar "Displays" list. (gud-expansion-speedbar-buttons): New function. (gud-speedbar-buttons): Check for gud-comint-buffer.
author Nick Roberts <nickrob@snap.net.nz>
date Sun, 09 Oct 2005 20:22:43 +0000
parents 69cb3967f4b5
children 1a3a5b662b90
files lisp/progmodes/gud.el
diffstat 1 files changed, 82 insertions(+), 84 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/gud.el	Sun Oct 09 20:21:38 2005 +0000
+++ b/lisp/progmodes/gud.el	Sun Oct 09 20:22:43 2005 +0000
@@ -336,9 +336,6 @@
 ;; speedbar support functions and variables.
 (eval-when-compile (require 'speedbar))	;For speedbar-with-attached-buffer.
 
-(defvar gud-last-speedbar-buffer nil
-  "The last GUD buffer used.")
-
 (defvar gud-last-speedbar-stackframe nil
   "Description of the currently displayed GUD stack.
 t means that there is no stack, and we are in display-file mode.")
@@ -355,7 +352,11 @@
     (define-key gud-speedbar-key-map "j" 'speedbar-edit-line)
     (define-key gud-speedbar-key-map "e" 'speedbar-edit-line)
     (define-key gud-speedbar-key-map "\C-m" 'speedbar-edit-line)
-    (define-key gud-speedbar-key-map "D" 'gdb-var-delete)))
+    (define-key gud-speedbar-key-map "D" 'gdb-var-delete))
+
+  (speedbar-add-expansion-list '("GUD" gud-speedbar-menu-items
+				 gud-speedbar-key-map
+				 gud-expansion-speedbar-buttons)))
 
 (defvar gud-speedbar-menu-items
   '(["Jump to stack frame" speedbar-edit-line
@@ -374,89 +375,86 @@
     (gud-install-speedbar-variables)
   (add-hook 'speedbar-load-hook 'gud-install-speedbar-variables))
 
+(defun gud-expansion-speedbar-buttons (directory zero)
+  "Wrapper for call to speedbar-add-expansion-list.   DIRECTORY and
+ZERO are not used, but are required by the caller."
+  (gud-speedbar-buttons gud-comint-buffer))
+
 (defun gud-speedbar-buttons (buffer)
   "Create a speedbar display based on the current state of GUD.
 If the GUD BUFFER is not running a supported debugger, then turn
-off the specialized speedbar mode."
-  (let ((minor-mode (with-current-buffer buffer gud-minor-mode)))
-    (cond
-     ((memq minor-mode '(gdbmi gdba))
-      (when (or gdb-var-changed
-		(not (save-excursion
-		       (goto-char (point-min))
-		       (let ((case-fold-search t))
-			 (looking-at "Watch Expressions:")))))
-	(erase-buffer)
-	(insert "Watch Expressions:\n")
-	(let ((var-list gdb-var-list))
-	  (while var-list
-	    (let* ((depth 0) (start 0) (char ?+)
-		   (var (car var-list)) (varnum (nth 1 var)))
-	      (while (string-match "\\." varnum start)
-		(setq depth (1+ depth)
-		      start (1+ (match-beginning 0))))
-	      (if (equal (nth 2 var) "0")
-		  (speedbar-make-tag-line 'bracket ?? nil nil
-					  (concat (car var) "\t" (nth 4 var))
-					  'gdb-edit-value
-					  nil
-					  (if (and (nth 5 var)
-						   gdb-show-changed-values)
-					      'font-lock-warning-face
-					    nil) depth)
-		(if (and (cadr var-list)
-			 (string-match varnum (cadr (cadr var-list))))
-		    (setq char ?-))
-		(speedbar-make-tag-line 'bracket char
-					'gdb-speedbar-expand-node varnum
-					(concat (car var) "\t" (nth 3 var))
-					nil nil nil depth)))
-	    (setq var-list (cdr var-list))))
-	(setq gdb-var-changed nil)))
-     (t (if (and (save-excursion
-		   (goto-char (point-min))
-		   (looking-at "Current Stack"))
-		 (equal gud-last-last-frame gud-last-speedbar-stackframe))
-	    nil
-	  (setq gud-last-speedbar-buffer buffer)
-	  (let ((gud-frame-list
-		 (cond ((eq minor-mode 'gdb)
-			(gud-gdb-get-stackframe buffer))
-		       ;; Add more debuggers here!
-		       (t (speedbar-remove-localized-speedbar-support buffer)
-			  nil))))
-	    (erase-buffer)
-	    (if (not gud-frame-list)
-		(insert "No Stack frames\n")
-	      (insert "Current Stack:\n"))
-	    (dolist (frame gud-frame-list)
-	      (insert (nth 1 frame) ":\n")
-	      (if (= (length frame) 2)
-		  (progn
-;	            (speedbar-insert-button "[?]"
-;				            'speedbar-button-face
-;				            nil nil nil t)
-		    (speedbar-insert-button (car frame)
-					     'speedbar-directory-face
-					     nil nil nil t))
-;	      (speedbar-insert-button "[+]"
-;				      'speedbar-button-face
-;				      'speedbar-highlight-face
-;				      'gud-gdb-get-scope-data
-;				      frame t)
-	      (speedbar-insert-button (car frame)
-				      'speedbar-file-face
-				      'speedbar-highlight-face
-				      (cond ((memq minor-mode '(gdbmi gdba gdb))
-					     'gud-gdb-goto-stackframe)
-					    (t (error "Should never be here")))
-					frame t)))
-;            (let ((selected-frame
-;	           (cond ((eq ff 'gud-gdb-find-file)
-;		          (gud-gdb-selected-frame-info buffer))
-;		         (t (error "Should never be here"))))))
-	    )
-	  (setq gud-last-speedbar-stackframe gud-last-last-frame))))))
+off the specialized speedbar mode.  BUFFER is not used, but are
+required by the caller."
+  (when (and (boundp 'gud-comint-buffer)
+	     gud-comint-buffer
+	     ;; gud-comint-buffer might be killed
+	     (buffer-name gud-comint-buffer))
+    (let ((minor-mode (with-current-buffer buffer gud-minor-mode)))
+      (cond
+       ((memq minor-mode '(gdbmi gdba))
+	(when (or gdb-var-changed
+		  (not (save-excursion
+			 (goto-char (point-min))
+			 (let ((case-fold-search t))
+			   (looking-at "Watch Expressions:")))))
+	  (erase-buffer)
+	  (insert "Watch Expressions:\n")
+	  (let ((var-list gdb-var-list))
+	    (while var-list
+	      (let* ((depth 0) (start 0) (char ?+)
+		     (var (car var-list)) (varnum (nth 1 var)))
+		(while (string-match "\\." varnum start)
+		  (setq depth (1+ depth)
+			start (1+ (match-beginning 0))))
+		(if (equal (nth 2 var) "0")
+		    (speedbar-make-tag-line 'bracket ?? nil nil
+					    (concat (car var) "\t" (nth 4 var))
+					    'gdb-edit-value
+					    nil
+					    (if (and (nth 5 var)
+						     gdb-show-changed-values)
+						'font-lock-warning-face
+					      nil) depth)
+		  (if (and (cadr var-list)
+			   (string-match varnum (cadr (cadr var-list))))
+		      (setq char ?-))
+		  (speedbar-make-tag-line 'bracket char
+					  'gdb-speedbar-expand-node varnum
+					  (concat (car var) "\t" (nth 3 var))
+					  nil nil nil depth)))
+	      (setq var-list (cdr var-list))))
+	  (setq gdb-var-changed nil)))
+       (t (if (and (save-excursion
+		     (goto-char (point-min))
+		     (looking-at "Current Stack:"))
+		   (equal gud-last-last-frame gud-last-speedbar-stackframe))
+	      nil
+	    (let ((gud-frame-list
+	    (cond ((eq minor-mode 'gdb)
+		   (gud-gdb-get-stackframe buffer))
+		  ;; Add more debuggers here!
+		  (t (speedbar-remove-localized-speedbar-support buffer)
+		     nil))))
+	      (erase-buffer)
+	      (if (not gud-frame-list)
+		  (insert "No Stack frames\n")
+		(insert "Current Stack:\n"))
+	      (dolist (frame gud-frame-list)
+		(insert (nth 1 frame) ":\n")
+		(if (= (length frame) 2)
+		(progn
+		  (speedbar-insert-button (car frame)
+					  'speedbar-directory-face
+					  nil nil nil t))
+		(speedbar-insert-button
+		 (car frame)
+		 'speedbar-file-face
+		 'speedbar-highlight-face
+		 (cond ((memq minor-mode '(gdbmi gdba gdb))
+			'gud-gdb-goto-stackframe)
+		       (t (error "Should never be here")))
+		 frame t))))
+	    (setq gud-last-speedbar-stackframe gud-last-last-frame)))))))
 
 
 ;; ======================================================================