Mercurial > emacs
comparison lisp/progmodes/compile.el @ 66119:bc2d2dc9f534
(compilation-goto-locus): Display the
compilation buffer first and the source buffer second, in case they're
in overlapping frames. Don't raise the compilation frame if it was the
selected window upon entry. Pass the `other-window' arg to
pop-to-buffer.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 16 Oct 2005 14:12:50 +0000 |
parents | cbc600deccb5 |
children | 11893f0cbfb1 0ca0d9181b5e |
comparison
equal
deleted
inserted
replaced
66118:c0fac24c378a | 66119:bc2d2dc9f534 |
---|---|
1676 | 1676 |
1677 (defun compilation-goto-locus (msg mk end-mk) | 1677 (defun compilation-goto-locus (msg mk end-mk) |
1678 "Jump to an error corresponding to MSG at MK. | 1678 "Jump to an error corresponding to MSG at MK. |
1679 All arguments are markers. If END-MK is non-nil, mark is set there | 1679 All arguments are markers. If END-MK is non-nil, mark is set there |
1680 and overlay is highlighted between MK and END-MK." | 1680 and overlay is highlighted between MK and END-MK." |
1681 (if (eq (window-buffer (selected-window)) | |
1682 (marker-buffer msg)) | |
1683 ;; If the compilation buffer window is selected, | |
1684 ;; keep the compilation buffer in this window; | |
1685 ;; display the source in another window. | |
1686 (let ((pop-up-windows t)) | |
1687 (pop-to-buffer (marker-buffer mk))) | |
1688 (if (window-dedicated-p (selected-window)) | |
1689 (pop-to-buffer (marker-buffer mk)) | |
1690 (switch-to-buffer (marker-buffer mk)))) | |
1691 ;; If narrowing gets in the way of going to the right place, widen. | |
1692 (unless (eq (goto-char mk) (point)) | |
1693 (widen) | |
1694 (goto-char mk)) | |
1695 (if end-mk | |
1696 (push-mark end-mk t) | |
1697 (if mark-active (setq mark-active))) | |
1698 ;; If hideshow got in the way of | |
1699 ;; seeing the right place, open permanently. | |
1700 (dolist (ov (overlays-at (point))) | |
1701 (when (eq 'hs (overlay-get ov 'invisible)) | |
1702 (delete-overlay ov) | |
1703 (goto-char mk))) | |
1704 | |
1705 ;; Show compilation buffer in other window, scrolled to this error. | 1681 ;; Show compilation buffer in other window, scrolled to this error. |
1706 (let* ((pop-up-windows t) | 1682 (let* ((from-compilation-buffer (eq (window-buffer (selected-window)) |
1707 ;; Use an existing window if it is in a visible frame. | 1683 (marker-buffer msg))) |
1684 ;; Use an existing window if it is in a visible frame. | |
1708 (pre-existing (get-buffer-window (marker-buffer msg) 0)) | 1685 (pre-existing (get-buffer-window (marker-buffer msg) 0)) |
1709 (w (let ((display-buffer-reuse-frames t)) | 1686 (w (if (and from-compilation-buffer pre-existing) |
1710 ;; Pop up a window. | 1687 ;; Calling display-buffer here may end up (partly) hiding |
1711 (display-buffer (marker-buffer msg)))) | 1688 ;; the error location if the two buffers are in two |
1689 ;; different frames. So don't do it if it's not necessary. | |
1690 pre-existing | |
1691 (let ((display-buffer-reuse-frames t) | |
1692 (pop-up-windows t)) | |
1693 ;; Pop up a window. | |
1694 (display-buffer (marker-buffer msg))))) | |
1712 (highlight-regexp (with-current-buffer (marker-buffer msg) | 1695 (highlight-regexp (with-current-buffer (marker-buffer msg) |
1713 ;; also do this while we change buffer | 1696 ;; also do this while we change buffer |
1714 (compilation-set-window w msg) | 1697 (compilation-set-window w msg) |
1715 compilation-highlight-regexp))) | 1698 compilation-highlight-regexp))) |
1716 ;; Ideally, the window-size should be passed to `display-buffer' (via | 1699 ;; Ideally, the window-size should be passed to `display-buffer' (via |
1717 ;; something like special-display-buffer) so it's only used when | 1700 ;; something like special-display-buffer) so it's only used when |
1718 ;; creating a new window. | 1701 ;; creating a new window. |
1719 (unless pre-existing (compilation-set-window-height w)) | 1702 (unless pre-existing (compilation-set-window-height w)) |
1703 | |
1704 (if from-compilation-buffer | |
1705 ;; If the compilation buffer window was selected, | |
1706 ;; keep the compilation buffer in this window; | |
1707 ;; display the source in another window. | |
1708 (let ((pop-up-windows t)) | |
1709 (pop-to-buffer (marker-buffer mk) 'other-window)) | |
1710 (if (window-dedicated-p (selected-window)) | |
1711 (pop-to-buffer (marker-buffer mk)) | |
1712 (switch-to-buffer (marker-buffer mk)))) | |
1713 ;; If narrowing gets in the way of going to the right place, widen. | |
1714 (unless (eq (goto-char mk) (point)) | |
1715 (widen) | |
1716 (goto-char mk)) | |
1717 (if end-mk | |
1718 (push-mark end-mk t) | |
1719 (if mark-active (setq mark-active))) | |
1720 ;; If hideshow got in the way of | |
1721 ;; seeing the right place, open permanently. | |
1722 (dolist (ov (overlays-at (point))) | |
1723 (when (eq 'hs (overlay-get ov 'invisible)) | |
1724 (delete-overlay ov) | |
1725 (goto-char mk))) | |
1720 | 1726 |
1721 (when highlight-regexp | 1727 (when highlight-regexp |
1722 (if (timerp next-error-highlight-timer) | 1728 (if (timerp next-error-highlight-timer) |
1723 (cancel-timer next-error-highlight-timer)) | 1729 (cancel-timer next-error-highlight-timer)) |
1724 (unless compilation-highlight-overlay | 1730 (unless compilation-highlight-overlay |