I would like to implement automatic collapse of compilation buffer to small size (but not close at a delete windows), such that upon successful compilation to window is shrunk to minimum size.
get-buffer-create
returns a buffer. how can I shrink-window
on window associated with that buffer? also, is there a way to store previous window size?
It is my first foray into emacs lisp programming, thank you for your help.
I believe there are two ways to solve this problem.
The first is to use the hook `'compilation-finish-functions', which is:
Which leads to a solution like this:
The only problem I have with that solution is that it assumes that success can be determined by finding the string "finished" in the result string.
The other alternative is to advise
'compilation-handle-exit
- which gets passed the exit-status explicitly. I wrote this advice which shrinks the window when the exit status is non-zero.Note: if the
*compilation*
window is still visible when you do your second compile, it will not be resized larger upon failure. If you want it to be resized, you'll need to specify a height instead ofnil
. Perhaps this would be to your liking (changing the first example):The
nil
was replaced with(/ (frame-height) 2)