简体   繁体   中英

How can I use `M-x` in `emacs -nw` in zshell

It is my first time to use emacs -nw . But I have problem at the first when I type Mx . In the minibuffer, it shows "Mark set" instead of Mx I don't know why it happens. How can I deal with it?

PS: My os is Macosx and I connect remote by using ssh and then I type emacs -nw but I cannot use Mx

Update:08/30/2015

When I see the options under Mx customize-group ns , it seems that Alt is actually used as Meta? Why it didn't works.

14Hide Ns Alternate Modifier: [Value Menu] meta |
15 [ State ]: STANDARD. |
16 This variable describes the behavior of the alternate or option key. More |

37Hide Ns Right Alternate Modifier: [Value Menu] Use the value of ns-alternate-modifier |
38 [ State ]: STANDARD. |
39 This variable describes the behavior of the right alternate or option key. More |

When using Emacs in the terminal (switch -nw ), you might not have a Meta key, depending on your platform etc. In particular, the Alt keyboard key might not function as the Meta key. You might find some information (eg here, or by googling) about how to get it working as Meta for your context (platform etc.), but you might not.

You can always use ESC (the Escape key) followed by a key to act the same as the Meta modifier applied to that key. For example, instead of Mx , you can use ESC x .

(You press and release ESC , and then do the same for x . ESC is not a modifier key -- you do not hold it pressed while hitting x .)

Your problem is that OSX is stealing the key. There are a few things which will make your life easier

  1. Install emacs using homebrew. The version which comes with OSX is old
  2. Use iterm2 instead of the default term.app - much better and feature rich
  3. In iterm2, you can set a key override for either the left or right option as +ESC, which will make it all work.

This will all work on a local machine, but you may run into additional problems if your connecting to a remote machine and running emacs there. It is a similar problem, your key settings may no be getting stolen/dropped by the ssh session - all depends on your terminal, your ssh config and the remote system.

Note that with emacs, you often don't need to run remote. Emacs comes with a built-in system called Tramp, which is very powerful. Using tramp, you can open remote directories and edit the files as if they were local files. You run emacs locally and tramp uses ssh to open the remote files, read the contents into the local emacs buffer and then write the changes back tot he remote file. Helps to have ssh keys setup so you don't have to worry about passwords (but you will need an ssh-agent to make this work easily).

In general, when you find emads does not respond to a key press, especailly if you try Ch k and nothing happens when you hit the key bindings you can't get to work, it is almost certain that something in-between you and emacs is stealing the keys - this is often the window manager or OS, but it can also be due to terminal emulators etc. In over 20 years of using emacs, I've never had emacs 'do nothing' when you hit a key combination - if emacs recieves the key input, it will respond with something, even if that something is to tell you there is no key binding for the keys you pressed. If emacs does absolutely nothing, you know the message just isn't get through!

在此处输入图像描述

  1. Open Terminal Preferences
  2. Select Profiles
  3. Keyboard
  4. Check the box for "Use Option as Meta Key"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM