Some buffers can be closed by being in them and pressing q such as the help buffer, doing C-h k M-x will open a help buffer describing the keybinding M-x. Although, the cursor will stay in the original buffer and when I done reading the help buffer, I'll move to it and press q. Is there a way to automatically move to the new buffer only when the new buffer can be closed with a q so I don't have to move to it after reading and can just hit q?

  • This is not an answer, but in the common case where you had only one window before creating the window showing the *Help* buffer, using C-x 1 seems easier to me when you are don't want to have the help there anymore. (And that is what Emacs suggests you do.)
    – pst
    Commented Aug 30, 2020 at 20:45
  • I am aware of C-x 1, but just being able to press q in the buffer feels more comfortable.
    – scribe
    Commented Aug 30, 2020 at 20:53
  • I can't imagine you actually want this. After any command which opened a different kind of buffer you would need to manually move there. E.g. o and C-o in dired would now do the same thing instead of different things, because switching directly to the selected buffer is no longer allowed. Please clarify the question if that isn't actually what you want.
    – phils
    Commented Aug 30, 2020 at 21:24

2 Answers 2


The easiest, and I think best, way to get behavior similar to what you describe is to customize option help-window-select to non-nil (M-x customize-option help-window-select).

If you do that then when a *Help* window is displayed it is selected (gets the focus). So you can just hit q.

(This doesn't work for all help commands, but it works for most. It works for all that are implemented using with-help-window.)

If you don't really want it selected, because you sometimes want to continue doing stuff in your original window before dismissing the help window, then you'll need to jump through some hoops to get (and even to carefully specify) the behavior you want.

C-h v help-window-select says:

help-window-select is a variable defined in help.el.

Its value is nil


Non-nil means select help window for viewing.

Choices are:

  • never (nil) Select help window only if there is no other window on its frame.

  • other Select help window if and only if it appears on the previously selected frame, that frame contains at least two other windows and the help window is either new or showed a different buffer before.

  • always (t) Always select the help window.

If this option is non-nil and the help window appears on another frame, then give that frame input focus too. Note also that if the help window appears on another frame, it may get selected and its frame get input focus even if this option is nil.

This option has effect if and only if the help window was created by with-help-window.

You can customize this variable.


The functions that bring up the *Help* window will sometimes move you to that window and sometimes not. That depends among other things on how many windows you had open before. In the common case where you only had one window it will stay there, since it's so easy to remove the other window with C-x 1 then. You get a message like

Type C-x 1 to delete the help window, C-M-v to scroll help.

But if you already had several windows and one of them is used for showing the *Help*it's not as easy, so you stay where you are and get:

Type "q" in help window to restore its previous buffer.

That is the default (and there are other possibilities as well, like when you have several frames), but it is configurable. If you would like to always be moved to the help buffer, Use Options→Customize Emacs→Specific Option to customize help-window-select, and you will see that you can choose "always".

You write "only when the new buffer can be closed with a q", but that is about showing help texts when that always apply. I don't know if you are thinking of other commands that display other buffers as well.

  • 1
    Like the buffer opened by magit can also be closed by a q. My question is not just about the help buffer, it is about any buffer that we can close with a q.
    – scribe
    Commented Aug 30, 2020 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.