In Emacs, what is byte-compilation?

本文介绍了Emacs中字节编译的功能,该功能可以将Lisp代码转换为字节码,提高执行效率并便于跨平台移植。文章还提供了如何进行文件及目录级别的字节编译操作,并给出了一种自动编译的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C

Byte-compilation is a function of Emacs that transforms Lisp into byte-code. Byte-code, run by an interpreter in Emacs, can be executed more quickly than Lisp. However, because it isn't written in machine code, it can be directly transferred between machines without having to be recompiled. Functions byte-compiled by earlier versions of Emacs can be correctly interpreted by Emacs, but the opposite is not necessarily true.

To byte-compile a file, launch Emacs and enter: M-x byte-compile-file RET [file to byte-compile] Replace [file to byte-compile] with the name of the file you want to compile. The compiler will take the file, which should end in the extension .el , and create a byte-code version with the extension .elc.

 

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

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) 

 

转载于:https://www.cnblogs.com/RichardLee/archive/2012/03/31/2426378.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值