2009-04-26 84 views

回答

13

把文件google.el目录中,说~/lisp,然后在你的.emacs:

(add-to-list 'load-path "~/lisp") 
(require 'google) 

如果要添加目录及其子目录,你可以检查出answers in this SO question

而且,随着您添加越来越多的'require行,您会注意到启动过程中的速度变慢。在这一点上,你会想知道如何make Emacs start up faster我当然喜欢my answer最好。

+0

这是否为.el文件工作嵌套在负载路径下的子目录?我不得不手动包含一些位于〜/ .emacs.d目录(存储我的.el文件的位置)以下的.el文件,虽然也许我做了错误的事情。 – bedwyr 2009-04-26 22:44:13

+0

不,它不适用于嵌套目录。但我已经添加了一个关于如何做到这一点的链接。 – 2009-04-26 23:01:32

1

elisp-load-dir可以帮助,如果你需要一次加载多个文件。 我用它来装载每个主题建立的文件,这反过来只有当自动加载实际需要重的东西:

.emacs 
.emacs.d/ 
    lisp/ 
    elisp-load-dir.el 
    ... other .el files that provide a feature 
    rc/ 
    ... many small .el file that set variables, defaults, etc for me 

所以我的.emacs真的是最小的,它只是增加了~/.emacs.d/lisp负载路径,从而使我可以在那里安装第三方扩展。然后,它需要elisp-load-dir,并使用它来加载任何配置文件,我在~/.emacs.d/rc

(add-to-list 'load-path "~/.emacs.d/lisp") 
(require 'elisp-load-dir) 
(elisp-load-dir "~/.emacs.d/rc") 
;; then comes all the custom-set-faces stuff that emacs puts there 

rc/*.el文件基本上是你放什么在你的.emacs,除了它的模块化。举例来说,我有一个针对每种模式我经常使用,一个用于启动,禁用启动画面,工具栏等...

+0

你能举一个例子说明你如何使用代码?例如,从工作设置移到freeTimeSettings。我是Lisp的新手。 – 2009-04-26 23:09:44

1

你也可以在你的.emacs文件中添加一个简单的负载声明:

(load "/path/to/library.el") 

坦率地说,我喜欢Trey的解决方案:它将所有.el文件保存在一个位置。

编辑:按照Trey的说法删除'require'语句。