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

前端 未结 6 2058
野性不改
野性不改 2021-01-29 17:40

I have decided to check out Emacs, and I liked it very much. Now, I\'m using the Emacs Starter Kit, which sort of provides better defaults and some nice customizations to defaul

相关标签:
6条回答
  • 2021-01-29 17:43

    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")'
    
    0 讨论(0)
  • 2021-01-29 17:46

    The command I use is M-x byte-force-recompile RET, it then asks the directory so, for example, I give it ~/.emacs.d/elpa/. It then recompiles everything in there, usually no need to delete .elc files first or mess with it in other ways.

    0 讨论(0)
  • 2021-01-29 17:54

    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.

    0 讨论(0)
  • 2021-01-29 18:03

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

    0 讨论(0)
  • 2021-01-29 18:06

    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.

    0 讨论(0)
  • 2021-01-29 18:09

    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

    0 讨论(0)
提交回复
热议问题