emacs - emacs23 / elisp: how to properly autoload this library? -
i upgrading emacs23. find emacs.el loads more slowly.
it's own fault really... have lot of stuff in there.
so trying autoload possible "required" emacs.el.
i have module exposes 12 entry points - interactive functions can call.
is correct approach have 12 calls autoload
in order insure module loaded regardless of function call? there problems approach? present performance issues?
if not that approach, what?
what want autoloads generated automatically, .emacs file remains pristine. packages have ;;;###autoload
lines in them already, , if not, can add them.
to manage this, can put packages in directory, ~/emacs/lisp
, , in there have file named update-auto-loads.el
contains:
;; put path 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 files in diretory containing file." (interactive) (let ((base (file-truename (file-name-directory (symbol-file 'update-autoloads-in-package-area 'defun))))) (require 'autoload) ;ironic, 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 file non-zero size 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))
if add 'update-autoloads-in-package-area
kill-emacs-hook
, loaddefs.el
automatically updated every time exit emacs.
and, tie together, add .emacs
:
(load-file "~/emacs/lisp/loaddefs.el")
now, when download new package, save in ~/emacs/lisp
directory, update loaddefs via m-x update-autoloads-in-package-area
(or exit emacs), , it'll available next time run emacs. no more changes .emacs
load things.
see question other alternatives speeding emacs startup: how can make emacs start-up faster?
Comments
Post a Comment