unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* compile.el's window management
@ 2005-10-12 17:11 Stefan Monnier
  0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 2005-10-12 17:11 UTC (permalink / raw)



I always use a dedicated window/frame for my *grep* buffers and when
I middle-click on one of the lines I get two things:
- first the frame showing the corresponding source line is raised
- second the frame holding *grep* is raised

Now if the two frames happen to overlap, I end up staring at the *grep*
rather than the corresponding source line.

For some reason I've only started to notice this recently.  I haven't been
able to link it to a change in compile.el or some other change in Emacs, so
I assume it's just my usage pattern that's changed,

In any case, I've been using the patch below which basically swaps the
two operations around.  Any objection to it?


        Stefan


Index: lisp/progmodes/compile.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
retrieving revision 1.387
diff -u -r1.387 compile.el
--- lisp/progmodes/compile.el	2 Oct 2005 11:06:59 -0000	1.387
+++ lisp/progmodes/compile.el	12 Oct 2005 17:10:31 -0000
@@ -1678,37 +1678,20 @@
   "Jump to an error corresponding to MSG at MK.
 All arguments are markers.  If END-MK is non-nil, mark is set there
 and overlay is highlighted between MK and END-MK."
-  (if (eq (window-buffer (selected-window))
-	  (marker-buffer msg))
-      ;; If the compilation buffer window is selected,
-      ;; keep the compilation buffer in this window;
-      ;; display the source in another window.
-      (let ((pop-up-windows t))
-	(pop-to-buffer (marker-buffer mk)))
-    (if (window-dedicated-p (selected-window))
-	(pop-to-buffer (marker-buffer mk))
-      (switch-to-buffer (marker-buffer mk))))
-  ;; If narrowing gets in the way of going to the right place, widen.
-  (unless (eq (goto-char mk) (point))
-    (widen)
-    (goto-char mk))
-  (if end-mk
-      (push-mark end-mk t)
-    (if mark-active (setq mark-active)))
-  ;; If hideshow got in the way of
-  ;; seeing the right place, open permanently.
-  (dolist (ov (overlays-at (point)))
-    (when (eq 'hs (overlay-get ov 'invisible))
-      (delete-overlay ov)
-      (goto-char mk)))
-
   ;; Show compilation buffer in other window, scrolled to this error.
-  (let* ((pop-up-windows t)
-	 ;; Use an existing window if it is in a visible frame.
+  (let* ((from-compilation-buffer (eq (window-buffer (selected-window))
+                                      (marker-buffer msg)))
+         ;; Use an existing window if it is in a visible frame.
          (pre-existing (get-buffer-window (marker-buffer msg) 0))
-         (w (let ((display-buffer-reuse-frames t))
-              ;; Pop up a window.
-              (display-buffer (marker-buffer msg))))
+         (w (if (and from-compilation-buffer pre-existing)
+                ;; Calling display-buffer here may end up (partly) hiding
+                ;; the error location if the two buffers are in two
+                ;; different frames.  So don't do it if it's not necessary.
+                pre-existing
+              (let ((display-buffer-reuse-frames t)
+                    (pop-up-windows t))
+	        ;; Pop up a window.
+                (display-buffer (marker-buffer msg)))))
 	 (highlight-regexp (with-current-buffer (marker-buffer msg)
 			     ;; also do this while we change buffer
 			     (compilation-set-window w msg)
@@ -1717,6 +1700,29 @@
     ;; something like special-display-buffer) so it's only used when
     ;; creating a new window.
     (unless pre-existing (compilation-set-window-height w))
+
+    (if from-compilation-buffer
+        ;; If the compilation buffer window was selected,
+        ;; keep the compilation buffer in this window;
+        ;; display the source in another window.
+        (let ((pop-up-windows t))
+          (pop-to-buffer (marker-buffer mk) 'other-window))
+      (if (window-dedicated-p (selected-window))
+          (pop-to-buffer (marker-buffer mk))
+        (switch-to-buffer (marker-buffer mk))))
+    ;; If narrowing gets in the way of going to the right place, widen.
+    (unless (eq (goto-char mk) (point))
+      (widen)
+      (goto-char mk))
+    (if end-mk
+        (push-mark end-mk t)
+      (if mark-active (setq mark-active)))
+    ;; If hideshow got in the way of
+    ;; seeing the right place, open permanently.
+    (dolist (ov (overlays-at (point)))
+      (when (eq 'hs (overlay-get ov 'invisible))
+        (delete-overlay ov)
+        (goto-char mk)))
 
     (when highlight-regexp
       (if (timerp next-error-highlight-timer)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-12 17:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-12 17:11 compile.el's window management Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).