How can I monitor when Emacs loads a library because of an autoloaded function, and also know the name of that function?
EXAMPLE: I type M-x eval-buffer
in a buffer where one of the functions uses setf
(and I have not previously used this function during my Emacs session). I would like to see a message similar to: "setf
called within name-of-function
, causing it to load macroexp.el
by virtue of a require
statement within gv.el
."
Here is a start ...
(defun load-tracing-function (orig-fun &rest args)
(message "`load' called with args %S" args)
(let ((res (apply orig-fun args)))
(message "`load' returned %S" res)
res))
(advice-add 'load :around #'load-tracing-function)
(defun require-tracing-function (orig-fun &rest args)
(message "`require' called with args %S" args)
(let ((res (apply orig-fun args)))
(message "`require' returned %S" res)
res))
(advice-add 'require :around #'require-tracing-function)