关于el的安装

关于el的安装

近来些询问比较基本的el的安装的文章,整理一篇关于el安装的吧,适于新手

Emacs的强大,在于它的开放性和可扩充性
(呵呵,这就是dddkk说“学习Emacs,你要相信来生,因为你一生不可能学会它的全部功能”的原因吧)

这主要得益于各种各样的使用elisp语言编写的el文件,他们大多是开放源码的,如果懂elisp的话,这就很爽了
不过如果不懂elisp,也不妨碍使用它

关于el的安装使用,欧觉得emacswiki.org写得比较清楚了,简单理一下
这里的说法具有普遍性
至于每个el具体的设置和使用,比如使用方法、键盘的绑定等,应该参考el文件本身,一般el文件的文件头部分是使用说明(不过是E文的哦 :)

(本文所有英文内容来自 http://emacswiki.org,我不过整理了一下)

*** 1.直接使用load

  如果不使用load-path(即文件不在load-path中),则应该

 Now you need to find your init file. For Emacs, that's "~/.emacs", for XEmacs that's "~/.xemacs/init.el". If the file does not exist yet, create it.

Put these two lines into the file:

    (load "C://Programs//emacs-wiki.el")
    (emacs-wiki-find-file "WelcomePage")  ;;这句不用管,是emac-wiki用的

In the first line you need to put the path to the file you downloaded.

***  2. 使用load-path

以上load命令需要给出确切的路径,如果将此路径设置到load-path里面,当使用el的时候,就可以直接使用,不用管路径了

就象下面这样,至于load-path的设置请看后面小节

Alternatively, if you followed the suggestions on the LoadPath page(下面的小节), you can replace the first line by the following one:


    (require 'emacs-wiki)

*** 3.设置load-path

至于使用load-path的方法,如下有几种,你可以选择自己喜欢的那种

#LoadPath
The variable load-path lists all the directories where Emacs should look for elisp files. They are searched in order. The first file found is used, therefore the order of the directories might be relevant.
Preference is given to compiled files when both a compiled file and a source file are found. Therefore, make sure to recompile files after making changes to them -- or don't compile the files at all.


Installing a new file
Make sure you have a local directory where you put elisp files. I use ~/elisp, for example.

Make sure this directory is listed in your `load-path' variable. I use the following statement in my ~/.emacs file to make sure it is:


    (add-to-list 'load-path "~/elisp")

XEmacs documentation (21.4 (patch 14)) for load-path says: "Note that the elements of this list *may not* begin with '~', so you must call expand-file-name on them before adding them to this list." So, for XEmacs, the above should be:


    (add-to-list 'load-path (expand-file-name "~/elisp"))

You can also add it to the EMACSLOADPATH environment variable, if you prefer.


Including subdirectories
By default Emacs doesn't include subdirectories of a directory which is added to load-path. But you can do it by issuing a command in startup file:


    (normal-top-level-add-subdirs-to-load-path)

which will add all subdirs of current directory. Note: current directory is not necessary the one where your script is executed at the moment. So you first need to change directory to the required one:


    (progn (cd "~/elisp") (normal-top-level-add-subdirs-to-load-path))

In this example it is assumed that you want to add all subdirs of the ~/elisp directory.


*** 4.查看问题和冲突解决

Debugging
First, check the value of your load-path by asking for help on the variable: `C-h v load-path RET' should give you the documentation for the variable and its current value. If your directory is not listed, you must add it (see above).

If your directory is listed, check for ConflictingLibraries.(见下面的部分)

如果发生冲突,比如以前系统本身有一个版本,你又新装了一个版本
下面是以guns为例,对于冲突(ConfictingLibraries)问题解决的介绍

#ConflictingLibraries
When you are installing a new copy of Gnus (eg. in your /usr/local/ tree), you will have two copies of Gnus: The one that came with Emacs, and the new one. This may cause problems, since you need to make sure that the right one is being loaded.
Files are loaded in order of the directories in the `load-path' variable. The first thing to check is therefore the value of `load-path'. If your .emacs file has statements that add new directories to your `load-path', check them to see wether they are correct.

Here is my example:


    (add-to-list 'load-path "~/elisp")
    (add-to-list 'load-path "~/elisp/bbdb/lisp")
    (add-to-list 'load-path "~/elisp/tnt")
    (add-to-list 'load-path "~/elisp/gnus/lisp")
    (add-to-list 'load-path "~/elisp/gnus/contrib")

Next, check whether any "shadowing" takes place. "Shadowing" happens when there are two files with the same name in different directories of your load path. In this case, you want the new copy of Gnus to shadow the old copy of Gnus.

M-x locate-library

Use the `locate-library' command to find which file is being loaded. This is rather tedious, however. Especially since you might not know all the files involved.

M-x list-load-path-shadows

This lists all the shadowed files. Don't be confused by the output. Mine lists 77 items. Most of them are local Gnus files (in ~/elisp/gnus/lisp/) shadowing the global Gnus files (in /usr/local/share/emacs/20.7/lisp/gnus/). The problem is this: If you installed a local copy of something which exists globally, you need to find the corresponding shadowing. If you installed Gnus and it doesn't shadow the original Gnus, then you are obviously still using the original Gnus -- Emacs doesn't find the new one.

You can do two things, then:


Delete the original files or rename the relevant directory. This might be difficult to do when you are not root. This will make errors in your setup very obvious. 
Add the correct directory (directories) to the front of your load-path. Do this in your .emacs file (or in the site-start.el file if you are installing new packages for every user on your system).

--
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值