How do I byte-compile everything in my .emacs.d directory?

非 Y 不嫁゛ 提交于 2019-12-02 13:47:43

C-u 0 M-x byte-recompile-directory

will compile all the .el files in the directory and in all subdirectories below.

The C-u 0 part is to make it not ask about every .el file that does not have a .elc counterpart.

To automatically byte compile everything that needs byte compiling each time I start emacs, I put the following after my changes to load-path at the top of my .emacs file:

(byte-recompile-directory (expand-file-name "~/.emacs.d") 0)

Surprisingly, it doesn't add much to my startup time (unless something needs to be compiled).

To speed up my emacs, I first identified the slow parts using profile-dotemacs.el and then replaced them with autoloads.

You can use the --batch flag to recompile from the command line.

To recompile all, do

emacs --batch --eval '(byte-recompile-directory "~/.emacs.d")'

or to recompile a single file as from a Makefile,

emacs --batch --eval '(byte-compile-file "your-elisp-file.el")'

This is swaying a bit from the question, but to solve the problem of loading slowly you can use the new daemon feature in Emacs 23.

"If you have a lot of support packages, emacs startup can be a bit slow. However, emacs 23 brings emacs --daemon, which enables you to start emacs in the background (for example when you log in). You can instantly pop up new emacs windows (frames) with emacsclient. Of course, you could already have an emacs 'server' in older versions, but being able to start it in the background makes this a much nicer solution"

From http://emacs-fu.blogspot.com/2009/07/emacs-23-is-very-near.html

For my using spacemacs, the command is spacemacs/recompile-elpa. The command byte-recompile-directory does not compile any file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!