Using benchmark-init, I see that helm files (helm-elisp, helm-mode, helm, etc.) are being required, but I don't have "(require 'helm)" or "(require 'helm-config)" or "(helm-mode 1)" anywhere in my init file. I'm using use-package, and all helm-related packages are deferred, including helm. Is there some direct way I can figure out where helm is being required from? I also want to find out where semantic is being required from.
1 Answer
I don't know of any standard way of doing this. However, you can fairly simply advice require
so that it keeps trace of who calls it.
(defvar my/require-tree nil)
(defun require--advice (orig-fun feature &rest args)
(setq my/require-tree
(append my/require-tree
(list (let ((my/require-tree (list feature)))
(apply orig-fun feature args)
my/require-tree)))))
(advice-add 'require :around 'require--advice)
If you put this at the beginning of your init file, you should at the end get something like this in the my/require-tree
variable:
((org
(calendar
(cal-menu
(calendar)))
(find-func)
(format-spec)
(org-macs)
(org-compat
(org-macs))
(ob-emacs-lisp
(ob
(org-macs)
(org-compat)
(ob-eval
(org-macs))
(ob-core
(ob-eval)
(org-macs)
(org-compat))
(ob-comint
(ob-core)
(org-compat)
(comint))
(ob-exp
(ob-core))))
;;...
)
(tramp
;;...
))
NB: You can use C-hvmy/require-tree
RET to see the contents of the variable in a nicely formatted way.
-
Thanks! This gives a somewhat better overview than benchmark/init. However, there are still some things at the top level that I'm confused about. For example, paredit appears at the top level (and the only package I use that requires paredit is autoloaded). I don't use linum either, but it is being required. I'm also curious as to where some libraries like f.el are first being loaded.– noctuidCommented Sep 24, 2015 at 16:20
(benchmark-init/show-durations-tree)
(or similar) at the end of yourinit.el
, instead of running it withM-x
(if it ishelm-M-x
, many helm-* requires might be made in a singlehelm-M-x
). I guess benchmark-init doesn't know (and doesn't care) when Emacs initialization is finished.(benchmark-init/deactivate)
. I had just made the mistake of not uncommenting it; thanks! That fixes the helm part of my problem.