eval-after-load vs. mode hook

后端 未结 1 1818
终归单人心
终归单人心 2020-11-29 17:44

Is there a difference between setting things for a mode using eval-after-load and using the mode hook?

I\'ve seen some code where define-key

相关标签:
1条回答
  • 2020-11-29 18:16

    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".

    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.

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