简体   繁体   中英

How to change settings on emacs initialization file?

I have just started using emacs (previously using vi), and it seems that emacs does not configure the alt key to be used as meta. I currently have no way to use the meta key. I have read that I can fix this by configuring certian things in the emacs initialization file. However, I do not know in which directory the file is located. And, while I have tried using many variants of the find command, either the terminal displays a message telling me that the file does not exist or I get one of many different permission denied messages. So, I am afraid this is a multi-part problem, and due to my lack of experience, I may not understand a response that assumes extensive prior knowledge.

Firstly, how do I find the emacs initialization file?

Secondly, how do I configure the settings of this file to make the alt key correspond to meta?

Thank you for your time.

As stated here , emacs looks for init file in few possible locations:

  • ~/.emacs
  • ~/.emacs.el
  • ~/.emacs.d/init.el

where ~ is your home directory. If you do not have any of these files, you can create your own. In this file, you will define most of your customizations. Some examples of other users init files:

About the meta key: there may be different causes to why is it not mapped to alt initially, and some of them are explained here . One of possible solutions is to add following line to your initialization file: (setq x-alt-keysym 'meta) . There is also another stack overflow question partially covering this question, it may contain something useful: link .
Also, try using ESC as meta key and see if that works.

First, the version of Emacs that comes with OS X is Emacs version 22 dating from 2007. I don't know why Apple don't include a newer version, but I would guess that they are prevented for doing so due to licensing issues. In addition, the bundled version only runs in a terminal window.

I would strongly recommend you to download a newer version, for example from www.emacsforosx.com .

Once this is installed, you can use the following to bind Meta to suitable keys:

(if (boundp 'ns-command-modifier)
    (setq ns-command-modifier 'meta))

(if (boundp 'ns-option-modifier)
    (setq ns-option-modifier nil))

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