i have been working with GNU emacs on a linux server but my keyboard is for mac. i have problem with defining alt key as meta. try (setq mac-command-modifier 'meta) in ~/.emacs.el and then eval-buffer but still esc key worked as meta.

  • esc is bound separately to meta via the variable meta-prefix-char. I personally have set that to nil for the past several years because I like having one additional modifier key. The alt key defaults to meta on Windows and OSX builds of Emacs. I'm not sure why it doesn't work on Linux out of the box. Another forum participant will need to chime in. If you are working in the terminal, instead of the GUI version of Emacs, that is also a factor. – lawlist May 29 '18 at 8:42
  • 2
    mac-command-modifier (aka ns-command-modifier) is defined in nsterm.m and ns-win.el, and will not be available unless Emacs was built on an OSX platform --with-ns. – lawlist May 29 '18 at 9:00
  • @lawlist thank you but i dont want to use esc.my problem is i use mac input keyboard but i work on linux system. – farzane May 29 '18 at 9:58
  • 1
    If you are running the Linux version of Emacs, are you running it through a terminal (Terminal, iTerm2, etc.) or are you running it through X11? If it's through a terminal then you need to tell the terminal, not emacs, to send the alt key as meta. – amitp May 29 '18 at 19:22
  • 1
    The server can't control the terminal settings. You'll need to go into your terminal app. If you're using Terminal, try Settings --> Profiles --> Keyboard --> Use Option as Meta key. If you're using iTerm2, try Settings --> Profiles --> Keys --> Left alt sends Meta (or Esc). – amitp Jun 9 '18 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.