开发者

How to make permament customizations in Emacs?

开发者 https://www.devze.com 2022-12-15 18:43 出处:网络
I was learning Vim and now I\'m experimenting with Emacs. In Vim, for instance, I could hide t开发者_如何学Che toolbar by adding a \"set\" command in the _vimrc file.

I was learning Vim and now I'm experimenting with Emacs. In Vim, for instance, I could hide t开发者_如何学Che toolbar by adding a "set" command in the _vimrc file.

How is the customization approach in Emacs, for instance, if I want to hide the toolbar?


Emacs is customised using scripts written in it's own variant of the lisp programming language called elisp.

The usual way emacs power users make customisations is to write snippets that will achieve the desired effect and in a .emacs file situated in their home areas. This file gets loaded up when emacs starts (similar to the .vimrc file for vim).

Hiding the tool bar for example is accomplished using

(tool-bar-mode nil) 

In your .emacs

I'd recommend that you first go through the manual and then if you're feeling curious the emacs lisp tutorial.


Alternatively, if you're not comfortable editing elisp, you can use the inbuilt customisation system. You can launch it using M-x customize RET (RET is "hit enter" in emacs speak and M-x is done by holding down (normally) the alt key and hitting x).

The customisation interface allows you to use select the features you want to enable disable (although the sheer number of these can get overwhelming) and 'save' the settings (which just writes out elisp code for the settings you selected into your .emacs file).


This answer addresses where Emacs stores customized settings, and how you can write your own customization settings to be loaded each time you start Emacs.

First, there's a file designated by the variable user-init-file that designates which user-specific file to load upon starting. Its value is usually the file .emacs within your home directory. Some versions of Emacs have used mangled names on Windows like _emacs on the assumption that the leading dot was intolerable. Somewhat confusingly, you can customize that variable too.

Absent a change to the normal behavior, Emacs will save customizations you make through its menus into this file. Hence, many users like to keep the customization ELisp code they've written by hand in a different file that Emacs won't disturb.

At the head of my ~/.emacs file, I have the following form:

(load-file "~/.emacs.d/init.el")

In a separate directory, ~/.emacs.d, I had a slew of ELisp files that the aforementioned init.el references, loading them under different conditions.

When running Emacs on a shared system (Linux, for example), there are usually site-related customization files that Emacs loads as well. That way, an administrator can make some settings available to all users, who can later override and extend those site-related settings in their own customization files.


I presume you did not try

M-x customize

which is just about the most obvious choice -- and also accessible via the menu.

Edit: If you want to hide the toolbar, try the menu via Options -> Show/Hide -> Toolbar.

0

精彩评论

暂无评论...
验证码 换一张
取 消