Don’t show compilation buffer unless there are errors

This commit is contained in:
Tom Willemse 2016-12-02 14:39:59 +01:00
parent a6a88fd424
commit 1b439d09a3
2 changed files with 36 additions and 7 deletions

View file

@ -477,6 +477,15 @@ To start off, first I need to enable lexical binding.
(add-hook 'minibuffer-setup-hook 'electric-pair-local-mode) (add-hook 'minibuffer-setup-hook 'electric-pair-local-mode)
#+END_SRC #+END_SRC
* Shackle
Shackle is an abstraction over =display-buffer-alist=.
#+BEGIN_SRC emacs-lisp
(require 'shackle)
(shackle-mode)
#+END_SRC
* Libraries * Libraries
- [[file:init/oni-shr-init.org][shr]] - [[file:init/oni-shr-init.org][shr]]
@ -753,7 +762,7 @@ To start off, first I need to enable lexical binding.
- [[file:init/oni-compilation-init.org][compilation-mode]] - [[file:init/oni-compilation-init.org][compilation-mode]]
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(with-eval-after-load 'compilation (load "oni-compilation-init")) (with-eval-after-load 'compile (load "oni-compilation-init"))
#+END_SRC #+END_SRC
** Inferior Emacs lisp mode (ielm) ** Inferior Emacs lisp mode (ielm)

View file

@ -1,21 +1,41 @@
#+TITLE: Compilation mode configuration #+TITLE: Compilation mode configuration
#+BEGIN_SRC emacs-lisp
(require 'compile)
(require 'shackle)
(require 'subr-x)
#+END_SRC
Scroll output in compilation mode. Scroll output in compilation mode.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq compilation-scroll-output t) (setq compilation-scroll-output t)
#+END_SRC #+END_SRC
Show compilation buffers in a side window. Don't show the compilation window when compilation starts.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-to-list 'display-buffer-alist (defun oni:maybe-dont-show-window (buffer-or-name alist plist)
`(,(rx bos "*compilation*" eos) "Don't show BUFFER-OR-NAME unless it absolutely must."
display-buffer-in-side-window)) (if (alist-get 'allow-no-window alist)
buffer-or-name
(funcall (plist-get plist :fallback) buffer-or-name alist
(plist-put (copy-sequence plist) :custom nil))))
(add-to-list 'shackle-rules
'(compilation-mode :custom oni:maybe-dont-show-window
:fallback shackle-display-buffer
:other t :select t))
#+END_SRC #+END_SRC
Bury compilation buffers on successful compilation. Show the compilation window when compilation has finished with a
non-zero exit status.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(bury-successful-compilation) (defun oni:maybe-display-compilation-window (buffer status)
"Display BUFFER if STATUS is not finished."
(unless (string= (string-trim status) "finished")
(display-buffer buffer)))
(add-hook 'compilation-finish-functions #'oni:maybe-display-compilation-window)
#+END_SRC #+END_SRC