Say I have two existing files named "file1.el" and "file2.el".
Then I perform the following steps:
I open a file named "file1.el"
C-x C-f
a file named "file2.el", now currently I have 1 window and it displays the "file2.el" buffer.I use
eval-expression
an expression(display-buffer "file1.el")
, it opens a new window that displaysfile1.el
buffer on the same frame.I want to kill the
file1.el
buffer and its corresponding window, so Ieval-expression
an expression(quit-window t (get-buffer-window "file1.el"))
, and I got what I want.
However, things are different when I do some buffer switches on the window displaying "file1.el", just after step 3. If I have done it, the step 4 will only kill the "file1.el" buffer, but NOT quitting the window that displaying it. Instead, after step 4, that window will display another buffer that I've switch to previously.
My question is that why quit-window
behavior is different in this scenario?
quit-window
usesquit-restore-window
to decide what to do: see their doc strings withC-h f quit-window
andC-h f quit-restore-window
.