Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using emacs in Cygwin and have used Autohotkey to re-map the lefthand 'Alt' key and the lefthand 'Windows' key to be (left)Ctrl and (left)Alt respectively.

This means that an emacs sequence like Ctrl-xCtrl-c is done with my left thumb pressing on the key labelled 'Alt' to produce the Ctrl. Ok.

All seems okay except that I cannot get M-SPC to work, so my question is to ask for help on that.

Here is the Autohotkey script I am using (by the way it is only for theoretical completeness that I re-map the lefthand Ctrl key to be the lefthand Windows button -- I have never actually pressed it when using emacs):

#IfWinActive ahk_class mintty

To be clear, when I say 'all is ok' I mean that within emacs I use the 'describe key sequence' feature (C-h then k) and then try out the key combination I want. For example, all of these show the emacs documentation for the sequence I expected:

  • Key labelled 'Alt' + g reports emacs documentation for C-g. Good.
  • Key labelled 'Alt' + SPACE reports the documentation for C-@, which emacs says is also mapped to C-SPC, so that seems okay. Good.
  • Key labelled 'MSWin Symbol' + x reports documentation for M-x. Good.
  • Key labelled 'MSWin Symbol' + key labelled 'Alt'+ k reports documentation for C-M-k. Good.


  • Key labelled 'MSWin Symbol' + SPACE shows me the 'right-click' menu for the cygwin window rather than taking me to the documentation for M-SPC. Bad.
  • By the way, I can get to the documentation for M-SPC by instead doing ESC followed by SPACE.

Let me add another point which has come up in the process of reacting to comments on this question:

  • Key labelled 'MSWin Symbol' + key labelled 'Alt'+ SPACE takes me to the documentation for C-@, so I suspect it is being understood by emacs as C-SPC rather than as C-M-SPC as I thought my Autohotkey script would map it to. Bad.

Any ideas on why Autohotkey won't do the M-SPC as I would expect, or why C-M-SPC is understood by emacs as a C-SPC (I suspect)?


share|improve this question

migrated from May 22 '13 at 10:21

This question came from our site for professional and enthusiast programmers.

Funnily enough, in another SO question that I am involved in (see the first comment in, Thomas mentions that C-M-SPC can be problematic in some terminals and explains that for him it does exactly what I am seeing here -- it produces a right-click menu for the terminal itself. – Robert Apr 9 '13 at 14:02
that's quite a weird remapping... Most people who do remap CTRL remap it to CAPS-LOCK. Also quite some expensive keyboards come with CTRL in place of CAPS-LOCK (which is where CTRL was on older keyboards btw), like the Happy Hacking Pro 2 for example. Note that if you're touch typing you'll find CTRL-x quite hard to do correctly, no matter where you put CTRL, so you can use Emacs and ctl-x-map to remap all the "C-x ..." shortcuts to something else (I'm using C-, instead of C-x). – user988052 Apr 10 '13 at 3:01
On my MacBook at home the CMD key sits next to the space-bar, ie. exactly where the Alt key is on my PC keyboard. On the MacBook the CMD key is often used in circumstances where Ctrl would be used on a PC. I got to like it. I did try the pinkie remapping of using the PC's CAPS-LOCK as the Ctrl but that hurts! My poor little finger was aching! Rather, with the PC's Alt as Ctrl you just tuck your (stronger) thumb under the arch of your fingers and bingo! there is Ctrl. Nicer, I think. On this one I would claim that Apple got the layout right (let's not discuss their placement of '#'). – Robert Apr 10 '13 at 8:08
You're complaining about "Key labelled 'Alt' + SPACE" being misunderstood; but you've made it clear that the Windows logo key is your Meta, so you should amend this to say "Key labelled 'MSWin Symbol' + SPACE". Unless I've really misunderstood something (not hard to do when you're talking about shifting so many keys around!) – echristopherson Apr 11 '13 at 21:01
@echristoperson You are right. I am about to correct that. Thank you. – Robert Apr 17 '13 at 16:31

Alt+Space is a standard Windows shortcut for showing the window menu, which you can also get by left-clicking on the window icon or right-clicking on the titlebar.

You can disable that shortcut on the Keys page of the Cygwin terminal's options (together with the Alt+Enter shortcut for fullscreen, for which Alt+F11 can be used instead).

share|improve this answer
Understood, and have un-set it in the terminal options. However, within emacs my 'test' of using C-h k to describe a key sequence tells me that C-M-SPC is interpreted as C-SPC (this was what Thomas actually explained in the comment I mentioned above). – Robert Apr 9 '13 at 14:09
You didn't say anything about C-M-SPC in your original question. FWIW, it works fine for me (not using AutoHotKey): "C-M-@ runs the command mark-sexp, which is an interactive compiled Lisp function. It is bound to C-M-@, C-M-SPC." – ak2 Apr 9 '13 at 14:38
My apologies, I had got a couple of sentences muddled in my original question. I am now updating it to correct those and to include mention of the problem with C-M-SPC only being seen as C-SPC by emacs. – Robert Apr 9 '13 at 15:05
Regarding C-M-SPC, does it work without the AHK script, pressing the actual Ctrl+Alt+SPC keys? – ak2 Apr 10 '13 at 8:29
Good point! Yes it does work: I turn off AHK and my C-h k test in emacs correctly takes me to the documentation for C-M-@ (bound to C-M-SPC as you will know) when I press Ctrl+Alt+SPACE. Thank you for the good question! That pretty-much proves that I do have a problem with my AHK script as I suspected (coz I am an AHK novice). – Robert Apr 10 '13 at 8:57

Here are answers to your problem:

Issues remaping ctrl to alt and alt to ctrl for Emacs

And a discussion of why that happens

Plus to the script that can be found following first link you can add this code to work will all possible keyboard layouts.

#IfWinNotActive, ahk_group HaveEmacsHotkeys
#InputLevel 1
; Aditionally remaps Window keys and AppsKey
    SetKeyDelay, -1
    Send, {Blind}{Alt DownTemp}
*RWin up::
    SetKeyDelay, -1
    Send, {Blind}{Alt Up}

    SetKeyDelay, -1
    Send, {Blind}{Alt DownTemp}
*LWin up::
    SetKeyDelay, -1
    Send, {Blind}{Alt Up}

    SetKeyDelay, -1
    Send, {Blind}{Alt DownTemp}
*AppsKey up::
    SetKeyDelay, -1
    Send, {Blind}{Alt Up}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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