I have tried to add global key-bindings to Emacs interactively via M-x global-set-key by following the guidelines in the Emacs Manual. When I add a keybinding though there is no confirmation prompt so that I can confirm binding the key I want. Yet the Manual states "After you press the key, a message ... appears so that you can confirm that you are binding the key you want." (https://www.gnu.org/software/emacs/manual/html_node/emacs/Rebinding.html)

If I then exit Emacs and reopen it, the global-key I have defined interactively does not work across sessions. Is this a bug? I have tried this without my default init and also in two versions of Emacs (25,26)

  • 1
    If you expect a key binding to persist across Emacs sessions then you need to put it in your init file. But your question is not clear, to me at least. Please provide a step-by-step recipe of what you're doing, preferably starting with emacs -Q (no init file). Say what you see at each step and what you expected to see instead.
    – Drew
    Commented Jan 21, 2019 at 7:19
  • You have already answered my question which is whether keys bound interactively persist across sessions. It seems from your answer that they do not unless one edits the init file directly. The Manual says that when a key is bound in this way, there is a confirmation message that pops up which asks the user to confirm their binding. When I add a key, I get no such request. I thought this was the reason the keys were not persisting, because I got no confirmation message.
    – Edman
    Commented Jan 21, 2019 at 10:30
  • 1
    Please add to your question that statement you see in the manual, and cite the location. If you think the text is mistaken you can file a bug report using M-x report-emacs-bug. Note that, as @heikki points out, you get the message only when you use global-set-key interactively, e.g., M-x global-set-key.
    – Drew
    Commented Jan 21, 2019 at 15:24

1 Answer 1


Like @Drew answered in the comments, interactively set keys do not persist across sessions.

Secondly, to answer to the title question, when you use global-set-key interactively, there is a confirmation prompt just like the manual page says.

The confirmation promt is the text that pops up after pressing the key combination and expects you to select the command to bind it to:

Set key C-z to command:

You were probably expecting an additional confirmation after executing the whole interactive command. That was not meant nor said to be there.

  • Yes, you are quite correct. I was expecting an additional confirmation.
    – Edman
    Commented Jan 21, 2019 at 11:51
  • I see that one can copy the key into the kill ring with a very long key and yank it into one's init. The Manual says: "To make the process of binding keys interactively easier, use the following “trick”: First bind the key interactively, then immediately type C-x <ESC> <ESC> C-a C-k C-g. Now, the command needed to bind the key is in the kill ring, and can be yanked into your .emacs file. "
    – Edman
    Commented Jan 21, 2019 at 12:03

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.