It looks like you can achieve what you want by temporarily disabling display-buffer via compilation-start .
This is a combination of what sds said and posted something in the comments @ here
The comment has a nasty problem with point jump in the original source buffer, which I apparently developed, also blocking set-window-point and goto-char . This sounds like a dirty hack, but it still works. YMMV!
(defun brian-compile-finish (buffer outstr) (unless (string-match "finished" outstr) (switch-to-buffer-other-window buffer)) t) (setq compilation-finish-functions 'brian-compile-finish) (require 'cl) (defadvice compilation-start (around inhibit-display (command &optional mode name-function highlight-regexp)) (if (not (string-match "^\\(find\\|grep\\)" command)) (flet ((display-buffer) (set-window-point) (goto-char)) (fset 'display-buffer 'ignore) (fset 'goto-char 'ignore) (fset 'set-window-point 'ignore) (save-window-excursion ad-do-it)) ad-do-it)) (ad-activate 'compilation-start)
Now you should see that all compilation buffers will be displayed only if outstr does not return the status of completed completion or a command launched using "find" or "grep."
assem source share