用 byte-compile 缓存 exec-path-from-shell 来加速 Emacs 启动

去掉exec-path-from-shell加快两秒启动时间 继续讨论:

文档上说 eval-when-compile 可以在 byte-compile 期间就会把值计算出来,所以这样的配置编译之后再加载应该会快一些了:

(use-package exec-path-from-shell
  :if (eq window-system 'ns)       ; Only for the official Cocoa Emacs
  :ensure t
  :defer t
  :init
  (let ((path (eval-when-compile
                (require 'exec-path-from-shell)
                (exec-path-from-shell-getenv "PATH"))))
    (setenv "PATH" path)
    (setq exec-path (append (parse-colon-path path) (list exec-directory)))))
6 个赞