summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmin Bandali <bandali@gnu.org>2018-12-22 12:58:48 -0500
committerAmin Bandali <bandali@gnu.org>2018-12-22 12:58:48 -0500
commitf79ed7c654cadb5f3b48a6aa7fecb4e7adcd95f8 (patch)
treedcba254412e47d9de061d00763a12e62c2683886
parent4e0afb99adeb6c013635ad7cf01d42416fb101b1 (diff)
downloadconfigs-f79ed7c654cadb5f3b48a6aa7fecb4e7adcd95f8.tar.gz
configs-f79ed7c654cadb5f3b48a6aa7fecb4e7adcd95f8.tar.xz
configs-f79ed7c654cadb5f3b48a6aa7fecb4e7adcd95f8.zip
[emacs] don’t display *compilation* on build success (uses cl-letf)
-rw-r--r--init.org39
1 files changed, 27 insertions, 12 deletions
diff --git a/init.org b/init.org
index 8763a02..f05e53c 100644
--- a/init.org
+++ b/init.org
@@ -646,18 +646,33 @@ Enable =winner-mode=.
(winner-mode 1)
#+end_src
-*** COMMENT Close =*compilation*= on success
+*** Don’t display =*compilation*= on success
+
+Based on https://stackoverflow.com/a/17788551, with changes to use
+=cl-letf= instead of the now obsolete =flet=.
#+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)))
+(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-macs)
+
+(setq ad-redefinition-action 'accept)
+(defadvice compilation-start
+ (around inhibit-display
+ (command &optional mode name-function highlight-regexp))
+ (if (not (string-match "^\\(find\\|grep\\)" command))
+ (cl-letf (((symbol-function 'display-buffer) #'ignore)
+ ((symbol-function 'set-window-point) #'ignore)
+ ((symbol-function 'goto-char) #'ignore))
+ (save-window-excursion ad-do-it))
+ ad-do-it))
+
+(ad-activate 'compilation-start)
#+end_src
*** Search for non-ASCII characters
@@ -827,8 +842,7 @@ file.
',file-tangle-start-time)))
""))
(when amin-async-tangle-post-compile
- (save-window-excursion
- (compile amin-async-tangle-post-compile))))
+ (compile amin-async-tangle-post-compile)))
(message "Tangling %s failed" ,file-nodir))))))))
(add-to-list
@@ -2266,6 +2280,7 @@ Display how long it took to load the init file.
(message "Loading %s...done (%.3fs)" user-init-file
(float-time (time-subtract (current-time)
amin--before-user-init-time)))
+(setq ad-redefinition-action 'warn)
#+end_src
* Footer