How come when I autoload some function advice, eg.
;;;###autoload
(advice-add 'eclimd-start :before #'(lambda () (require 'some-library))
and then call eclimd-start, the library from which the advice is autoloaded isn't loaded? I thought I would be able to just use the following to get the file with the settings loaded before calling the function as well,
;;;###autoload
(advice-add 'eclimd-start :before (lambda () nil)
In this case the library contains settings to be used by the function eclimd-start. So, as a reproducible example, it could be
(setq eclimd-default-workspace "/hdd/workspace")
;;;###autoload
(defun my-java-hook () nil)
;;;###autoload
(advice-add 'eclimd-start :before
#'(lambda () (require 'some-library))
(provide 'some-library)
and the autoloads are created as usual into a file loaded at startup.
The effect of the
;;;###autoloadis defined in an ad-hoc way depending on the thing it annotates. For function definitions, it turns into a call to theautoloadfunction that will cause the file to be loaded when the annotated function is called, but for pretty much everything else, the annotated sexp is just copied to the autoload file.So in your case, the
;;;###autoloadonmy-java-hookcauses the autoloads file to contain something like(autoload 'my-java-hook "some-library"), but the same;;;###autoloadyou placed in front of the advice will simply cause the autoloads file to contain(advice-add 'eclimd-start ...).What you can do, tho is: