I like to work with a vertically split frame with code in both windows. When i call M-x compile the *compilation* buffer shows in the other window (wich is fine as M-g n would show problematic code in the current window while i can still see the error in the other), but, after reviewing code, i would like to kill the *compilation* buffer and show the code that was in that window before, without visiting that window (C-x o) and killing it (C-x k).
Is there a way to do that?
I've come up with something, altough, it does not work; it throws:
wrong-type-argument windowp (#<window 10 on *Backtrace*>))`
window-buffer((#<window 10 on *Backtrace*>))
I believe that window-buffer does take a window as an argument and return its buffer, but I don't know any Lisp.
The code:
(defun kill-other-window-buffer ()
"Kill the buffer of the other window if there is two windows"
;; I thought it will be better this way, to avoid killing an unexpected buffer
;; when several windows are in the frame
(if (= (length (window-list)) 2)
(kill-buffer
(window-buffer (last (window-list)))
)))