emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/progmodes/gdb-ui.el


From: Nick Roberts
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/gdb-ui.el
Date: Tue, 15 Feb 2005 04:19:13 -0500

Index: emacs/lisp/progmodes/gdb-ui.el
diff -c emacs/lisp/progmodes/gdb-ui.el:1.47 emacs/lisp/progmodes/gdb-ui.el:1.48
*** emacs/lisp/progmodes/gdb-ui.el:1.47 Wed Feb  9 19:42:09 2005
--- emacs/lisp/progmodes/gdb-ui.el      Tue Feb 15 09:19:13 2005
***************
*** 79,84 ****
--- 79,86 ----
  (defvar gdb-overlay-arrow-position nil)
  (defvar gdb-server-prefix nil)
  (defvar gdb-flush-pending-output nil)
+ (defvar gdb-location-list nil "List of directories for source files.")
+ (defvar gdb-find-file-unhook nil)
  
  (defvar gdb-buffer-type nil
    "One of the symbols bound in `gdb-buffer-rules'.")
***************
*** 191,196 ****
--- 193,227 ----
    :group 'gud
    :version "22.1")
  
+ (defun gdb-set-gud-minor-mode (buffer)
+   "Set gud-minor-mode from find-file if appropriate."
+   (goto-char (point-min))
+   (unless (search-forward "No source file named " nil t)
+     (condition-case nil
+       (gdb-enqueue-input
+        (list (concat gdb-server-prefix "info source\n")
+              `(lambda () (gdb-set-gud-minor-mode-1 ,buffer))))
+       (error (setq gdb-find-file-unhook t)))))
+ 
+ (defun gdb-set-gud-minor-mode-1 (buffer)
+   (goto-char (point-min))
+   (if (and (search-forward "Located in " nil t)
+          (looking-at "\\S-*")
+          (string-equal (buffer-file-name buffer)
+                        (match-string 0)))
+       (with-current-buffer buffer
+       (set (make-local-variable 'gud-minor-mode) 'gdba)
+       (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))))
+ 
+ (defun gdb-set-gud-minor-mode-existing-buffers ()
+   (dolist (buffer (buffer-list))
+     (let ((file (buffer-file-name buffer)))
+       (if file
+       (progn
+         (gdb-enqueue-input
+          (list (concat "list " (file-name-nondirectory file) ":1\n")
+                `(lambda () (gdb-set-gud-minor-mode ,buffer)))))))))
+ 
  (defun gdb-ann3 ()
    (setq gdb-debug-log nil)
    (set (make-local-variable 'gud-minor-mode) 'gdba)
***************
*** 249,254 ****
--- 280,286 ----
    (setq gdb-server-prefix "server ")
    (setq gdb-flush-pending-output nil)
    (setq gdb-location-list nil)
+   (setq gdb-find-file-unhook nil)
    ;;
    (setq gdb-buffer-type 'gdba)
    ;;
***************
*** 263,268 ****
--- 295,301 ----
    (gdb-enqueue-input (list "server list MAIN__\n" 'ignore))   ; Fortran 
program
    (gdb-enqueue-input (list "server info source\n" 'gdb-source-info))
    ;;
+   (gdb-set-gud-minor-mode-existing-buffers)
    (run-hooks 'gdba-mode-hook))
  
  (defcustom gdb-use-colon-colon-notation nil
***************
*** 1048,1055 ****
    ;; buffer specific functions
    gdb-info-breakpoints-custom)
  
- (defvar gdb-location-list nil "List of directories for source files.")
- 
  (defconst breakpoint-xpm-data
    "/* XPM */
  static char *magick[] = {
--- 1081,1086 ----
***************
*** 1159,1171 ****
                           (setq file (cdr (assoc bptno gdb-location-list))))
                        (unless (string-equal file "File not found")
                          (if file
!                             (with-current-buffer
!                                 (find-file-noselect file)
!                               (save-current-buffer
!                                 (set (make-local-variable 'gud-minor-mode)
                                     'gdba)
!                                 (set (make-local-variable 'tool-bar-map)
!                                      gud-tool-bar-map))
                                ;; only want one breakpoint icon at each 
location
                                (save-excursion
                                  (goto-line (string-to-number line))
--- 1190,1200 ----
                           (setq file (cdr (assoc bptno gdb-location-list))))
                        (unless (string-equal file "File not found")
                          (if file
!                             (with-current-buffer (find-file-noselect file)
!                               (set (make-local-variable 'gud-minor-mode)
                                     'gdba)
!                               (set (make-local-variable 'tool-bar-map)
!                                    gud-tool-bar-map)
                                ;; only want one breakpoint icon at each 
location
                                (save-excursion
                                  (goto-line (string-to-number line))
***************
*** 2054,2068 ****
    "Find the source file where the program starts and displays it with related
  buffers."
    (goto-char (point-min))
!   (if (search-forward "Located in " nil t)
!       (if (looking-at "\\S-*")
!         (setq gdb-main-file (match-string 0))))
   (if gdb-many-windows
        (gdb-setup-windows)
     (gdb-get-create-buffer 'gdb-breakpoints-buffer)
!     (if gdb-show-main
!       (let ((pop-up-windows t))
!       (display-buffer (gud-find-file gdb-main-file))))))
  
  (defun gdb-get-location (bptno line flag)
    "Find the directory containing the relevant source file.
--- 2083,2097 ----
    "Find the source file where the program starts and displays it with related
  buffers."
    (goto-char (point-min))
!   (if (and (search-forward "Located in " nil t)
!          (looking-at "\\S-*"))
!       (setq gdb-main-file (match-string 0)))
   (if gdb-many-windows
        (gdb-setup-windows)
     (gdb-get-create-buffer 'gdb-breakpoints-buffer)
!    (if gdb-show-main
!        (let ((pop-up-windows t))
!        (display-buffer (gud-find-file gdb-main-file))))))
  
  (defun gdb-get-location (bptno line flag)
    "Find the directory containing the relevant source file.
***************
*** 2085,2090 ****
--- 2114,2135 ----
        (goto-line (string-to-number line))
        (gdb-put-breakpoint-icon (eq flag ?y) bptno))))
  
+ (add-hook 'find-file-hook 'gdb-find-file-hook)
+ 
+ (defun gdb-find-file-hook ()
+   (if (and (not gdb-find-file-unhook)
+          ;; in case gud or gdb-ui is just loaded
+          gud-comint-buffer
+          (buffer-name gud-comint-buffer)
+          (with-current-buffer gud-comint-buffer
+            (eq gud-minor-mode 'gdba)))
+       (condition-case nil
+       (gdb-enqueue-input
+        (list (concat "list " (file-name-nondirectory buffer-file-name)
+                      ":1\n")
+              `(lambda () (gdb-set-gud-minor-mode ,(current-buffer)))))
+       (error (setq gdb-find-file-unhook t)))))
+ 
  ;;from put-image
  (defun gdb-put-string (putstring pos &optional dprop)
    "Put string PUTSTRING in front of POS in the current buffer.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]