(while compilation-in-progress
(accept-process-output)
- (sit-for 1))
+ ;; If sit for indicates that input is waiting, then
+ ;; read and discard whatever it is that is going on.
+ (when (not (sit-for 1))
+ (read-event nil nil .1)
+ ))
(with-current-buffer "*compilation*"
(goto-char (point-max))