]> code.delx.au - gnu-emacs/commitdiff
(gud-display-line): If the current file is newer than its
authorNick Roberts <nickrob@snap.net.nz>
Mon, 20 Jan 2003 22:03:50 +0000 (22:03 +0000)
committerNick Roberts <nickrob@snap.net.nz>
Mon, 20 Jan 2003 22:03:50 +0000 (22:03 +0000)
buffer, offer to reread the file.
(gud-keep-buffer): New buffer local variable. Ensures offer to
reread file is made just once.

lisp/gud.el

index 08b0ee92f330f7e49d69c7a2609b617734228aa3..862ecd3e38f19b66f0906e67f695655f50305803 100644 (file)
@@ -71,6 +71,8 @@ Supported debuggers include gdb, sdb, dbx, xdb, perldb, pdb (Python), jdb, and b
 (defvar gud-minor-mode nil)
 (put 'gud-minor-mode 'permanent-local t)
 
+(defvar gud-keep-buffer nil)
+
 (defun gud-symbol (sym &optional soft minor-mode)
   "Return the symbol used for SYM in MINOR-MODE.
 MINOR-MODE defaults to `gud-minor-mode.
@@ -188,7 +190,8 @@ Uses `gud-<MINOR-MODE>-directories' to find the source files."
       ;; Copy `gud-minor-mode' to the found buffer to turn on the menu.
       (with-current-buffer buf
        (set (make-local-variable 'gud-minor-mode) minor-mode)
-       (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))
+       (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
+       (make-local-variable 'gud-keep-buffer))
       buf)))
 \f
 ;; ======================================================================
@@ -2513,17 +2516,25 @@ Obeying it means displaying in another window the specified file and line."
        (progn
          (save-excursion
            (set-buffer buffer)
+           (if (not (or (verify-visited-file-modtime buffer) gud-keep-buffer))
+               (progn
+                 (if
+                     (yes-or-no-p 
+                      (format "File %s changed on disk.  Reread from disk? "
+                              (buffer-name)))
+                     (revert-buffer t t)
+                   (setq gud-keep-buffer t))))
            (save-restriction
              (widen)
              (goto-line line)
              (setq pos (point))
              (setq overlay-arrow-string "=>")
              (or overlay-arrow-position
-                 (setq overlay-arrow-position (make-marker)))
+             (setq overlay-arrow-position (make-marker)))
              (set-marker overlay-arrow-position (point) (current-buffer)))
            (cond ((or (< pos (point-min)) (> pos (point-max)))
-                  (widen)
-                  (goto-char pos))))
+           (widen)
+           (goto-char pos))))
          (set-window-point window overlay-arrow-position)))))
 
 ;; The gud-call function must do the right thing whether its invoking