summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmin Bandali <bandali@gnu.org>2018-12-22 00:45:03 -0500
committerAmin Bandali <bandali@gnu.org>2018-12-22 00:46:26 -0500
commit74a56f48afc4f55b7989cb6f1b3e84b0ce8e0878 (patch)
treeacc669fa3af6ec6b3a794fbf371bb68992a0c6d9
parentf1149591ecba2cb36ba9ea47a85fd1d12b5701db (diff)
downloadconfigs-74a56f48afc4f55b7989cb6f1b3e84b0ce8e0878.tar.gz
configs-74a56f48afc4f55b7989cb6f1b3e84b0ce8e0878.tar.xz
configs-74a56f48afc4f55b7989cb6f1b3e84b0ce8e0878.zip
[emacs] don’t display *compilation* on successful builds
-rw-r--r--init.org41
1 files changed, 29 insertions, 12 deletions
diff --git a/init.org b/init.org
index 787d386..d7af98c 100644
--- a/init.org
+++ b/init.org
@@ -650,18 +650,35 @@ Enable =winner-mode=.
(winner-mode 1)
#+end_src
-*** Close =*compilation*= on success
-
-#+begin_src emacs-lisp
-(setq compilation-exit-message-function
- (lambda (status code msg)
- "Close the compilation window if successful."
- ;; if M-x compile exits with 0
- (when (and (eq status 'exit) (zerop code))
- (bury-buffer)
- (delete-window (get-buffer-window (get-buffer "*compilation*"))))
- ;; return the result of compilation-exit-message-function
- (cons msg code)))
+*** Don’t display =*compilation*= on success
+
+From https://stackoverflow.com/a/17788551.
+
+#+begin_src emacs-lisp
+(defun amin--compilation-finish-function (buffer outstr)
+ (unless (string-match "finished" outstr)
+ (switch-to-buffer-other-window buffer))
+ t)
+
+(setq compilation-finish-functions #'amin--compilation-finish-function)
+
+(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)
#+end_src
*** Search for non-ASCII characters