How do I avoid conflicting hotkeys between Windows and Cygwin?

1

I am running Org-Mode in Cygwin's emacs. Org-mode uses the key combination of Alt+Enter to add a new line at your current level.

However, Windows uses Alt+Enter to toggle full-screen of a window. Is there a way I can prevent this conflict so that Windows doesn't toggle the window state while I'm in Cygwin?

sdasdadas

Posted 2013-05-30T16:29:06.263

Reputation: 125

@techie007 Not a duplicate; overriding M-RET via AHK or similar won't solve the problem, which in any case has only to do with running Emacs in a Windows console anyway -- see my answer. – Aaron Miller – 2013-05-30T16:34:32.233

The problem here is it's an XY problem. But as-is, the question is "How do I override Windows' hotkeys", and therefore it's a dupe (IMO). :)

– Ƭᴇcʜιᴇ007 – 2013-05-30T16:38:58.627

@techie007 I don't know if I even agree that it's an XY problem; I'm not sure how it could've been asked differently without prior knowledge, which the asker didn't have, that the observed M-RET behavior is specific to the Windows console and not a systemwide shortcut like the CUA stuff discussed in the first question you linked. That being the case, I maintain the contention that it's not a dupe, and the correct answer, as detailed below, is not "use AutoHotkey" but "use a real terminal emulator". :) – Aaron Miller – 2013-05-30T16:43:04.107

Perhaps something like "...However, Windows uses Alt-Enter to toggle full-screen of a window so it conflicts. How can I avoid this conflict?" instead of "How can I disable Alt-Enter in Windows?" – Ƭᴇcʜιᴇ007 – 2013-05-30T16:45:16.530

@techie007 I've edited the title to something, maybe, a bit more problem-oriented. – sdasdadas – 2013-05-30T16:56:03.257

@sdasdadas Nice, and I just edited the body to try and bring it more in line with the actual problem as well. :) This is a reason why it takes 5 people to vote something closed, so you have time to correct it. ;) – Ƭᴇcʜιᴇ007 – 2013-05-30T17:01:24.373

Answers

2

Only the Windows console (cmd.exe) treats M-RET in that fashion; run your shell, and Emacs, in a proper terminal emulator such as mintty or rxvt, to solve the problem and get a much more pleasant experience besides. (mintty comes with Cygwin by default, and is considerably better in my experience than rxvt, xterm, or any other terminal emulator available in the Cygwin package manager; unlike those relics of a bygone era, mintty has capabilities roughly on par with modern Linux terminal emulators.)

If you want to get really fancy, which I recommend, then install an X server -- Cygwin packages one, and there's also the third-party Xming version; I've had better results with Xming, but haven't tried Cygwin's X server in long enough that it's probably just as good by now -- and run Emacs in graphical mode, which not only resolves the M-RET problem but also gives you proper color and font support.

Aaron Miller

Posted 2013-05-30T16:29:06.263

Reputation: 8 849

I just tried mintty and it seems to have the same problem? – sdasdadas – 2013-05-30T16:35:55.473

3Huh. Apparently mintty by default treats M-RET the same way the Windows console does -- I forgot I'd disabled that; in any case, you can disable it via right-click on the window icon -> 'Options' -> 'Keys' and uncheck 'Menu and Full Screen shortcuts'. You also lose M-SPC to open the window menu, but I'd argue that capturing a key combination like that one is undesirable in a terminal emulator anyway, especially one in which Emacs is running. Sorry, I should've mentioned that in my answer. – Aaron Miller – 2013-05-30T16:39:00.407

Ah, that worked perfectly. And... I now know how to run an X server in Cygwin (which also worked, but needed a bit of boot up time). Thanks for the two options! – sdasdadas – 2013-05-30T16:40:27.943

Glad to be of help! – Aaron Miller – 2013-05-30T16:44:04.533

"Only the Windows console (cmd.exe) treats M-RET in that fashion" - I don't know what it is I'm missing, but since when has Alt+Enter ever done anything to the Command Prompt in Win7? – Karan – 2013-05-31T02:27:11.583

@Karan I can't answer "since when...", although it seems probable the correct answer is "since there's been Windows 7"; the M-RET behavior described has been a "feature" of the Windows console since IIRC Windows 95. But it definitely does attempt to fullscreen the window. (The VM in which I've just tried it complained that "The system does not support fullscreen mode", but that implies that it would've fullscreened the window if the system did support said mode.) – Aaron Miller – 2013-05-31T15:55:53.830

@AaronMiller: I know well what Alt+Enter did on Win95-XP. AFAIK on Vista+ the Command Prompt window cannot be set to full-screen and Alt+Enter does nothing, unless you're using legacy XPDM drivers instead of WDDM ones. If you have WDDM drivers it displays that error message. I'm guessing the OP has old drivers installed, possibly on hardware that didn't receive driver updates (or on old emulated hardware), otherwise he wouldn't be talking about Alt+Enter going full-screen in Win7. – Karan – 2013-05-31T18:17:10.380