Remapping Mac Modifier Keys on Emacs 23.3

I just switched from Carbon Emacs (which is old Emacs 22.x) to Emacs for OS X Modified on my Mac (which is a Cocoa app, and Emacs 23.3).

One of the unwelcome changes was that the Emacs ‘Meta’ modifier is now by default mapped to the Option key and not Command as before. But this gave me the opportunity to learn how to map the Mac keyboard modifier keys arbitrarily. I now have the following in my .emacs:

I’m documenting it here just in case someone (or my future self, when I need to redo my configuration at some point) finds it useful.