我正在升级到emacs23.我发现我的emacs.el加载速度要慢得多.
真的是我自己的错......那里有很多东西.
所以我也试图自动加载我的emacs.el目前"必需"的一切可能.
我有一个公开12个入口点的模块 - 我可以调用的交互式功能.
是否有正确的方法进行12次调用,autoload以确保模块加载,无论我调用哪个函数?这种方法有什么问题吗?它会出现性能问题吗?
如果没有这种方法,那又怎样?
Tre*_*son 22
您真正想要的是自动为您生成自动加载,以便您的.emacs文件保持原始状态.大多数软件包已经包含了这些;;;###autoload行,如果没有,您可以轻松添加它们.
要管理它,你可以将所有的包放在一个目录中,比如说~/emacs/lisp,并且有一个名为的文件update-auto-loads.el包含:
;; put this path into the load-path automatically
;;;###autoload
(progn
(setq load-path (cons (file-name-directory load-file-name) load-path)))
;;;###autoload
(defun update-autoloads-in-package-area (&optional file)
"Update autoloads for files in the diretory containing this file."
(interactive)
(let ((base (file-truename
(file-name-directory
(symbol-file 'update-autoloads-in-package-area 'defun)))))
(require 'autoload) ;ironic, i know
(let ((generated-autoload-file (concat base "loaddefs.el")))
(when (not (file-exists-p generated-autoload-file))
(with-current-buffer (find-file-noselect generated-autoload-file)
(insert ";;") ;; create the file with non-zero size to appease autoload
(save-buffer)))
(cd base)
(if file
(update-file-autoloads file)
(update-autoloads-from-directories base)))))
;;;###autoload
(defun update-autoloads-for-file-in-package-area (file)
(interactive "f")
(update-autoloads-in-package-area file))
Run Code Online (Sandbox Code Playgroud)
如果添加'update-autoloads-in-package-area到您的kill-emacs-hook,则loaddefs.el每次退出Emacs时都会自动更新.
并且,要将它们组合在一起,请将其添加到您的.emacs:
(load-file "~/emacs/lisp/loaddefs.el")
Run Code Online (Sandbox Code Playgroud)
现在,当您下载新软件包时,只需将其保存在~/emacs/lisp目录中,通过M-x update-autoloads-in-package-area(或退出emacs)更新loaddef ,它将在您下次运行Emacs时可用..emacs加载东西不再需要更改.
有关加速Emacs启动的其他替代方案,请参阅此问题:如何让Emacs启动更快?