summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2007-12-27 03:31:20 +0000
committerRichard M. Stallman <rms@gnu.org>2007-12-27 03:31:20 +0000
commit2d0a22f8260605bab25db423b0acc929bb48dce5 (patch)
treef8775bf4210972031f08490bc492221ca56c9f0f
parent9f9695a64085d0425c860215dee2de4579ac6d22 (diff)
downloademacs-2d0a22f8260605bab25db423b0acc929bb48dce5.tar.gz
(compilation-start): Set initial visible point properly even when
compilation buffer already current.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/compile.el57
2 files changed, 39 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7eb76ce1539..22bb4198dc7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-27 Richard Stallman <rms@gnu.org>
+
+ * progmodes/compile.el (compilation-start): Set initial visible
+ point properly even when compilation buffer already current.
+
2007-12-26 Richard Stallman <rms@gnu.org>
* files.el (conf-mode-maybe): New function.
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index a978415d59e..8d2f3a02c00 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1055,10 +1055,6 @@ Returns the compilation buffer created."
command "\n")
(setq thisdir default-directory))
(set-buffer-modified-p nil))
- ;; If we're already in the compilation buffer, go to the end
- ;; of the buffer, so point will track the compilation output.
- (if (eq outbuf (current-buffer))
- (goto-char (point-max)))
;; Pop up the compilation buffer.
(setq outwin (display-buffer outbuf nil t))
(with-current-buffer outbuf
@@ -1083,10 +1079,18 @@ Returns the compilation buffer created."
(set (make-local-variable 'revert-buffer-function)
'compilation-revert-buffer)
(set-window-start outwin (point-min))
- (or (eq outwin (selected-window))
- (set-window-point outwin (if compilation-scroll-output
- (point)
- (point-min))))
+
+ ;; Position point as the user will see it.
+ (let ((desired-visible-point
+ ;; Put it at the end if `compilation-scroll-output' is set.
+ (if compilation-scroll-output
+ (point-max)
+ ;; Normally put it at the top.
+ (point-min))))
+ (if (eq outwin (selected-window))
+ (goto-char desired-visible-point)
+ (set-window-point outwin desired-visible-point)))
+
;; The setup function is called before compilation-set-window-height
;; so it can set the compilation-window-height buffer locally.
(if compilation-process-setup-function
@@ -1105,7 +1109,10 @@ Returns the compilation buffer created."
(setq mode-line-process '(":%s"))
(set-process-sentinel proc 'compilation-sentinel)
(set-process-filter proc 'compilation-filter)
- (set-marker (process-mark proc) (point) outbuf)
+ ;; Use (point-max) here so that output comes in
+ ;; after the initial text,
+ ;; regardless of where the user sees point.
+ (set-marker (process-mark proc) (point-max) outbuf)
(when compilation-disable-input
(condition-case nil
(process-send-eof proc)
@@ -1119,21 +1126,25 @@ Returns the compilation buffer created."
(setq mode-line-process ":run")
(force-mode-line-update)
(sit-for 0) ; Force redisplay
- (let* ((buffer-read-only nil) ; call-process needs to modify outbuf
- (status (call-process shell-file-name nil outbuf nil "-c"
- command)))
- (cond ((numberp status)
- (compilation-handle-exit 'exit status
- (if (zerop status)
- "finished\n"
- (format "\
+ (save-excursion
+ ;; Insert the output at the end, after the initial text,
+ ;; regardless of where the user sees point.
+ (goto-char (point-max))
+ (let* ((buffer-read-only nil) ; call-process needs to modify outbuf
+ (status (call-process shell-file-name nil outbuf nil "-c"
+ command)))
+ (cond ((numberp status)
+ (compilation-handle-exit 'exit status
+ (if (zerop status)
+ "finished\n"
+ (format "\
exited abnormally with code %d\n"
- status))))
- ((stringp status)
- (compilation-handle-exit 'signal status
- (concat status "\n")))
- (t
- (compilation-handle-exit 'bizarre status status))))
+ status))))
+ ((stringp status)
+ (compilation-handle-exit 'signal status
+ (concat status "\n")))
+ (t
+ (compilation-handle-exit 'bizarre status status)))))
;; Without async subprocesses, the buffer is not yet
;; fontified, so fontify it now.
(let ((font-lock-verbose nil)) ; shut up font-lock messages