Emacs in Mac OS Lion terminal - map right command key to meta - emacs

I just started using GNU Emacs on my Mac OS X Lion and I am trying to ease up my hand movement through various key bindings. Specifically, I want to be able to use the right command key for meta.
The following code in my .emacs file does the trick for the standalone application (Emacs.app)
;;; cmd key for meta
(setq mac-option-key-is-meta nil
mac-command-key-is-meta t
mac-command-modifier 'meta
mac-option-modifier 'none)
(Snippet taken from this Superuser answer)
but does not work with emacs run in terminal mode. The meta there is still the alt/option key which I set from the Terminal.app preferences. When I disable this option key, I lose the meta key capability all together.
Any ideas?

i'm not aware of terminal providing you with the ability to deal with the left/right command key mappings. iterm2 provides the means to accomplish what you're looking for there. albeit at a global basis for iterm2.

There appears to be keyremap4macbook that may save you some time if you must use emacs in terminal. I can take no credit for this, but this guy can

Related

M-x not working for 2 days in Emacs

I do use Emacs for years, and in particular the Cygwin Emacs version (under Windows 10) for months.
Since 2 days, M-x combo key is not working anymore, well ESC x but I don't want to be forced to use Emacs à la Vi ;-)
First, I thought that the keyboard of my laptop could have a trouble, but the same effect is observed with an external keyboard connected by USB.
Second, I though it could be due to some changes I did in my own Emacs init file, or changes inherited from MELPA. To test that, I came back into time with Git, but that wasn't it: problem still observed; to test for MELPA packages, I used a minimal Emacs (emacs -q) and, once again, the problem still persists.
(And ESC x displays that M-x, translated from <escape> x, runs the command
execute-extended-command -- which is expected.)
Finally, what's weird, is that the key x alone is working, and so does C-x. On the other hand, M (meta) is working: M-c, M-w do work like expected.
So, to sum up, only the particular combination M-x is not working, and I really have no idea why.
Any smart test I could do to debug this (on Win 10)?
To sum up the answer in the comments:
If your key combination does not do what you expect - use C-h k to find out if it's a wrong mapping inside emacs, or something is grabbing this combination before emacs has a chance. If C-h k doesn't do anything in response to Alt-X - then you can be certain emacs doesn't see it at all.
If you want to confirm a key combination has been hijacked try to use some other application with it. Alt-X isn't used by regular Windows applications, but if you happen to have anything else that can have customized key bindings then try to map Alt-X to anything inside it. Eclipse, IntelliJ, Visual Studio, gvim. But seeing what happens with C-h k is a sufficient proof.
To find out what is stealing your Alt-X check what was installed or reconfigured lately. Disable startup programs if you can't recall. Additionally, from my experience a couple of nasty offenders: Intel video driver, and Windows language bar. (Not with Alt-X, with other key combinations.) Windows language bar is especially annoying when it steals C-S-) which I use for slurp.
Last thing. If you are running in a VM, your key combination may be stolen at either host or guest level (or both, as I've seen with the language bar.) So you may need to look around in both places.
I encountered the same problem. But I found that the problem was come up with the conflict of hotkey. On my Win10 OS, M-w is conflicted with the Tencent QQ software. So when I closed the QQ or changed the QQ's hotkey, the Emacs worked well.
I don't know why, but the problem is with Growl for windows v2.0.8. Close it and emacs will run normally.
Anyways, any new program setup could create conflicts. Stop all new (since the bug) process and check it.
(I don't want to change the keys configuration)

Remap meta key to other key on the keyboard

I have a programmable mechanical keyboard and can place any key anywhere.
At our company we recently switched to windows PCs and so that broke my emacs configuration because of the dreaded windows key which I tried to map to Meta but never got it to work.
Basically I use tigervnc to run vnc session that runs on linux.
Running emacs under linux in the VNC on a windows machine is a pain.
Every time I click the windows button to act as a meta the windows menu popup.
Anyways, I wonder if I can map Meta key to say "insert key", and the program the keyboard to have "insert" in place of "windows key" and vice versa.
I am also using ALT for other configurations so I don't want to map meta to ALT since I sometimes use all three combinations "Ctrl+ALT+Meta"+F-keys.
Is there a way to do so?
It would help if you can tell us which keyboard you own.
If it supports QMK firmware, you can just create two layers of keymaps for regular Windows usage and for VNC.
I think you will need to peruse Keymaps for Translating Sequences of Events (function-key-map et al).

Emacs tty evil / viper ESC key stand-alone

There are several vim clone packages for Emacs (Evil, Viper..). These packages have a special built in functionality where they remap the Escape key for tty users. I'm not sure how this is done (With a timeout?).
I'd like this functionality as well however I don't want to use the entire Evil / Viper package, I only want the Escape key functionality. This is because I use God Mode, basically Vim's normal / Insert mode with emacs keybindings instead. It doesn't however have a solution for the TTY Escape key like Evil / Viper do. My Elisp isn't really good enough to implement this myself.
So if there is a stand alone package for the escape key issue I'd love to hear about it.
This doesn't /really/ answer my question but I've found something nice that solves my problem.
Xcape is a tool that you can use change the behavior of a key. For example if you run this command:
xcape -e 'Control_L=Control_L|G'
When pressing Left Control and releasing right away, it will act as Control-G. If you hold down Control it will simply act as Control normally does.
Now if I remap C-g to active God-mode I get the expected behavior in the terminal as well. And you can change the keys to however you want.
As I said this doesn't really answer my question but it does solve the problem. So I'll just leave this answer for other people to find.

Emacs: how to swap ctrl and alt using configure file?

Before posting this question, I've read this so thread and have a brief view on the emacs wiki.
However, all the guides above use a system-wide keymapping or some key binding software. As emacs can be configured, is there any way to swap the ctrl and alt key using the ~/.emacs configure file?
By default Alt key is not mapped to a emacs modifier. Each OS does it differently. So you will need an OS depended solution:
On Windows try use the key binding functions of EmacsW32.
On Mac OSX use the built-in ns-command-modifier, ns-control-modifier and ns-option-modifier.
In Emacs for OS X there is a settings group for this: M-x customize-group RET ns RET
see link
Unfortunately I was not able to find similar settings for the other OSes. But maybe you can hack your own based on the code for ns.

Option or Command key as Meta key for LispBox on Macintosh

I'm new to emacs and have just downloaded LispBox (from the Practical Common Lisp page) with SBCL to my Macintosh. I do know enough to realize I want either the option or Command key to be the meta key.
The emacs version delivered with LispBox doesn't pay attention to .emacs in my home directory.
Emacs as delivered with LispBox fires up into a REPL. I can't figure out what I should type to set up a command key as Meta, nor where or how to configure it permanently.
Edit: I'm not really interested in loading up another version of emacs. I already have emacs running from the Terminal with my option key mapped as meta. Being able to closely follow the "Practical Common Lisp" tutorial, which assumes LispInABox, is what I'm interested in here.
TIA.
Navigate to /Applications/Lispbox/Emacs.app/Contents/MacOS and edit lispbox.sh, removing the --no-init-file parameter. Then, inside ~/.emacs, add (setq mac-command-modifier 'meta)
As an alternative check out Ready Lisp for Mac OS X. It uses Aquamacs for Emacs.
Aquamacs is a specially for Mac OS X enhanced GNU Emacs.
If you run Emacs in a Mac OS X terminal, you can set the Option key to be the Meta key using the 'Preferences' dialog.