I'd like to minimize emacs on Windows, when I press the Alt-Space, then n keys, just like with other Windows programs (because Alt-Space opens the program's menu that includes the 'Mi_n_imize' option, and 'n' then tells Windows to minimize that program/window)

I've rebound my left alt to be my Meta key.

So I want to set things up so that Meta-Space n will invoke (suspend-frame)

I tried this:

(global-set-key (kbd "M-SPC n") 'suspend-frame) 

But I got the error message Key sequence M-SPC n starts with non-prefix key M-SPC

Is there a clear explanation of what 'prefix' vs. 'non-prefix' keys are?

Is there a way to work around this, and to use Meta-Space in a key sequence?

UPDATE: I've found the GNU Emacs manual entry for prefix keys as well as this Wiki page on adding prefix keys but the following doesn't work:

(define-prefix-command 'keymap-meta-space)
(global-set-key (kbd "M-SPC") 'keymap-meta-space )
(define-key keymap-meta-space (kbd "M-n") 'suspend-frame)

After evaluating all three sexp's I press M-SPC, then I press n, and then emacs waits for me to press something else (by displaying M-SPC n- in the minibuffer).

2 Answers 2


M-SPC is bound to just-one-space by default, which is a command, not a prefix key. In order to be able to bind M-SPC n, you'd have to unbind it first:

(global-unset-key (kbd "M-SPC"))
(global-set-key (kbd "M-SPC n") #'suspend-frame) 
  • I must have been doing something wrong before - when I add those three lines to my init.el (the (define-prefix-command...) etc) everything seems to work fine (even without the (global-unset-key) ). Any ideas what that would be? Jul 29, 2018 at 19:23
  • If I understand things correctly it seems reasonable that my 3 lines would just replace M-SPC with a new keymap, thus not requiring a global-unset-key Jul 29, 2018 at 19:24
  • Emacs will automatically create new keymaps for prefixes, so you don't need to define them by hand.
    – user12563
    Jul 29, 2018 at 19:38
  • I thought so too. But this: (global-set-key (kbd "M-SPC n") 'suspend-frame ) produces the error message "Key sequence M-SPC n starts with non-prefix key M-SPC" Jul 30, 2018 at 1:23
  • Ha ha, I finally put 2 and 2 together. First I do global-unset-key like you said, then I do a normal (global-set-key (kbd "M-SPC n") 'suspend-frame ) and everything works great. Thanks for the tip! Jul 30, 2018 at 1:31

This actually did work, once I put it into my init.el and restarted emacs:

(define-prefix-command 'keymap-meta-space)
(global-set-key (kbd "M-SPC") 'keymap-meta-space )
(define-key keymap-meta-space (kbd "n") 'suspend-frame)

; and, just in case I don't release the Meta key fast enough:
(define-key keymap-meta-space (kbd "M-n") 'suspend-frame) 

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.