I run a command that takes over another window, and maybe resizes it a little, but doesn't focus it. Let's say C-h e or C-x C-b.
I can go to that window and press q there, and everything goes back to the previous state (the window resizes back, its previous content is restored, focus is back to the original window).
I want to be get the same effect without having to go to that window. Instead of C-h e C-x o q I want to be able to do C-h e <some keystroke that will close the most recently opened closeable-by-pressing-q window>.
(Months later) I found a simpler and more straightforward way... sometimes the simpler things elude us... (I'm leaving the "solved" mark where it is anyway):
(defun quit-other-window () (interactive) (other-window 1) (quit-window)) (global-set-key (kbd "C-c q") #'quit-other-window)