X11 on MacOS X and CMD-W

The most annoying thing with X11 on Mac is the shortcut CMD-W, especially when you are an Emacs user. On Emacs, CMD-W or META-W is the shortcut to put your selection into the cut buffer. But on Mac this is also the shortcut to close the window. This means that every time you type META-W on Emacs your Emacs window closes and you loose everything you are doing.

This recipe will explain how to remove the annoying CMD-W shortcut on X11.

First you need to have Apple’s developer kit called XCode installed. This is free and can be downloaded from Apple’s website here

As you can see on the screenshot below the shortcut is defined in the “Window menu” of the X11 application. To remove this short cut we just need to remove the keys definition (CMD-W) from that menu entry.

The easiest way to do that is to remove the menu item from the Window menu pane. Following these few easy steps can do this.

  1. the very first thing is to quit X11

  2. Open the Terminal.app and type the following command to open the resource file with the Interface Builder.

    
    $ open /Applications/Utilities/X11.app/Contents/Resources/English.lproj/main.nib
    
    If you are French or German select the appropriate language

  3. Select the MainMenu pane, then the menu item Window and then the item Close Window. Once the close Close Window item is selected hit the key delete.

  4. you can now save and quit the Interface builder

  5. Restart X11

The menu item Close Window and the short cut CMD-W don’t exist any more. You can type META-W in your Emacs window without losing your work.

 

Leave a message

(Required)
(Required and not displayed)
(Optional)
obfuscated letters Enter the text shown in the image