Minimize emacs on Windows with Meta-Space, n?

MikeTheTall 07/29/2018. 2 answers, 102 views
microsoft-windows frames

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

DoMiNeLa10 07/30/2018.

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) 

MikeTheTall 07/29/2018.

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) - Download Hi-Res Songs

1 Elohim

Holding Hands flac

Elohim. 2019. Writer: Quinn XCII;Jeremy Zucker;Elohim;Danny Parra;Corey Berkowitz;Antonina Armato.
2 P!nk

Walk Me Home flac

P!nk. 2019. Writer: P!nk;Scott Harris;Nate Ruess.
3 Katy Perry

365 flac

Katy Perry. 2019. Writer: Zedd;Katy Perry;Caroline Ailin;Corey Sanders;Daniel Davidsen;Cutfather;Peter Wallevik.

Happy flac

DEAMN. 2019.
5 Ariana Grande

7 Rings flac

Ariana Grande. 2019. Writer: Ariana Grande;Richard Rodgers;TBHits;Njomza;Michael "Mikey" Foster;Kaydence;Tayla Parx;Scootie;Oscar Hammerstein II;Victoria Monét.
6 5 Seconds Of Summer

Who Do You Love flac

5 Seconds Of Summer. 2019. Writer: Andrew Taggart;Talay Riley;Oak;Sean Douglas;Luke Hemmings;Calum Hood;Ashton Irwin;Michael Clifford;Trevorious;Zaire Koalo.
7 Bonn

No Sleep flac

Bonn. 2019. Writer: Albin Nedler;Bonn;Martin Garrix.
8 Bruno Mars

Please Me flac

Bruno Mars. 2019. Writer: J. White Did It;DJ White Shadow;Philip Lawrence;Bruno Mars;Cardi B.
9 Brooks

Better When You're Gone flac

Brooks. 2019. Writer: David Guetta;Emma Lov Block;Ido Zmishlany;Jackson Foote;Jeremy Dussolliet;Brooks.
10 Ariana Grande

Imagine flac

Ariana Grande. 2019. Writer: JProof;Priscilla Renea;Happy Perez;Andrew "Pop" Wansel;Ariana Grande.
11 Avril Lavigne

Dumb Blonde flac

Avril Lavigne. 2019. Writer: Mitch Allan;Bonnie McKee;Nicki Minaj;Avril Lavigne.
12 Avril Lavigne

Birdie flac

Avril Lavigne. 2019. Writer: J.R. Rotem;Avril Lavigne.
13 Ariana Grande

Thank U, Next flac

Ariana Grande. 2019. Writer: Crazy Mike;Scootie;Victoria Monét;Tayla Parx;TBHits;Ariana Grande.
14 Ariana Grande

Fake Smile flac

Ariana Grande. 2019. Writer: Joseph Frierson;Mary Frierson;Fred Ball;Happy Perez;Andrew "Pop" Wansel;Wendy Rene;Kennedi Lykken;Priscilla Renea;Justin Tranter;Ariana Grande.
15 Avril Lavigne

Warrior flac

Avril Lavigne. 2019. Writer: Chad Kroeger;Travis Clark;Chris Baseford;Avril Lavigne.
16 Nichkhun

Home flac

Nichkhun. 2019.
17 Dua Lipa

Swan Song flac

Dua Lipa. 2019. Writer: Dua Lipa;Justin Tranter;Kennedi Lykken;Mattias Larsson;Robin Fredriksson;Junkie XL.
18 Dimitri Vegas & Like Mike

Selfish flac

Dimitri Vegas & Like Mike. 2019. Writer: Victor Thell;Michael Thivaios;Maria Smith;Jeff Porcaro;Dimitri Thivaios;David Paich;Dan Book;Will Grands;ANGEMI.
19 Jason Derulo

Let's Shut Up And Dance flac

Jason Derulo. 2019. Writer: Bongo.
20 Ariana Grande

Needy flac

Ariana Grande. 2019. Writer: Tayla Parx;TBHits;Victoria Monét;Ariana Grande.

Related questions

Hot questions


Popular Tags