4

I have an Italian keyboard layout. My left Alt/Option key does not behave as the Meta key in Emacs terminal (OS X), but it behaves as the Meta key in GNU Emacs (GUI) downloaded from https://emacsformacosx.com

How can I get my left Alt/Option key to act as Meta? It prints .

3 Answers 3

3

After making sure the right alt key is setup in the Terminal app as @junnu suggested, you can do the following to free up the right option key for the special characters you need:

(setq mac-right-option-modifier nil)

EDIT: Was a bit too quick, as I now read that you want to change the behaviour of the left option key...

Anyway, here is a suggestion: take a look at the variable ns-alternate-modifier and its documentation (with C-h v). What is this variable's value in your current configuration?


EDIT 2: As pointed out by Stefan, this only affects the GUI setup. This setting is part of ns-win.el and thus only loaded in a windowed environment.

1
  • 1
    All these options only affect the GUI case, not the case where Emacs is running inside a terminal.
    – Stefan
    Commented Oct 19, 2018 at 16:51
1

http://osxdaily.com/2013/02/01/use-option-as-meta-key-in-mac-os-x-terminal/

  1. Open Terminal and pull down the primary Terminal menu to choose “Preferences”
  2. Under the “Settings” section, find your default Terminal and click the “Keyboard” subsetting tab
  3. Check the little box for “Use option as meta key” at the bottom of the window
2
  • @junnu this does not work since I use right alt to press @#[] {} characters in the italian layout. If I bind option as meta as you suggested, these characters will not work. I ONLY need the left alt key as meta, the right should be left/option like now. Commented Oct 19, 2018 at 10:52
  • 4
    This is, I think, the right answer, but it might be a good idea to suggest using iTerm instead of Terminal.app as it lets you set the left and right option keys separately.
    – Alan Third
    Commented Oct 19, 2018 at 12:37
0

It sounds like your problem isn't with emacs but with your chosen keyboard layout on the Mac. The Mac lets you customize such things in enormous detail using XML keyboard layout files that you can load. I'd look in to doing that.

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