Commits

Anonymous committed 046dcab

Window selection fixes

  • Participants
  • Parent commits d567580

Comments (0)

Files changed (4)

+1998-04-24  SL Baur  <steve@altair.xemacs.org>
+
+	* gdb.el:
+	* gdbsrc.el: Improve selection of window for display.
+	From David Hughes <djh@videonetworks.com>
+
 1998-01-24  SL Baur  <steve@altair.xemacs.org>
 
 	* Makefile (VERSION): Update to package standard 1.0.
 
 # This XEmacs package contains independent single file lisp packages
 
-VERSION = 1.01
+VERSION = 1.02
 AUTHOR_VERSION =
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = debug
 ;; and that its line LINE is visible.
 ;; Put the overlay-arrow on the line LINE in that buffer.
 
+;; David Hughes 24th April 1998
+(defun gdb-display-window (source-buffer line)
+  ;; Searches frame for the most appropriate source window
+  ;; BUFFER to display
+  ;; LINE number to display
+  (let ((source-pos
+         (eval-in-buffer source-buffer
+           (save-excursion (goto-line line) (point)))))
+    (catch 'found
+      (save-window-excursion
+        (select-window (or (get-buffer-window current-gdb-buffer)
+                           (selected-window)))
+        (walk-windows
+         (function
+          (lambda (w)
+            (and (eq source-buffer (window-buffer w))
+                 (pos-visible-in-window-p source-pos w)
+                 (throw 'found w))))))
+      (display-buffer source-buffer))))
+
 (defun gdb-display-line (true-file line &optional select-method)
   ;; FILE to display
   ;; LINE number to highlight and make visible
   (let* ((pre-display-buffer-function nil) ; screw it, put it all in one screen
 	 (pop-up-windows t)
 	 (source-buffer (find-file-noselect true-file))
-	 (source-window (display-buffer source-buffer))
+	 (source-window (gdb-display-window source-buffer line))
 	 (debugger-window (get-buffer-window current-gdb-buffer))
          (extent gdb-arrow-extent)
 	 pos)
   ad-do-it
   (save-excursion
     (let* ((buf (extent-object gdb-arrow-extent))
-	   (win (get-buffer-window buf)))
+	   (win (gdb-display-window buf line)))
       (setq gdbsrc-last-src-buffer buf)
       (select-window win)
       (set-window-point win (extent-start-position gdb-arrow-extent))