且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

加载后评估与模式挂钩

更新时间:2023-11-30 15:38:58

包裹在 eval-after-load 中的代码只会被执行一次,所以它通常用于执行一次性设置,例如作为设置默认全局值和行为.一个例子可能是为特定模式设置默认键盘映射.在eval-after-load 代码中,没有当前缓冲区"的概念.

Code wrapped in eval-after-load will be executed only once, so it is typically used to perform one-time setup such as setting default global values and behaviour. An example might be setting up a default keymap for a particular mode. In eval-after-load code, there's no notion of the "current buffer".

模式挂钩对启用模式的每个缓冲区执行一次,因此它们用于每个缓冲区的配置.因此,模式挂钩的运行时间晚于 eval-after-load 代码;这让他们可以根据当前缓冲区中是否启用其他模式等信息采取行动.

Mode hooks execute once for every buffer in which the mode is enabled, so they're used for per-buffer configuration. Mode hooks are therefore run later than eval-after-load code; this lets them take actions based upon such information as whether other modes are enabled in the current buffer.