Genehack is probably right; I'm being too literal in answering the question. The best way to handle something like this is to figure out which function(s) are required by external code, and add autoload
s for them.
But if autoload
won't work in your case, the normal way to do something when a file is loaded is to do
(eval-after-load "semantic" '(load "cedet"))
But I just noticed that you say that semantic.el fails to load if CEDET hasn't been loaded first. As implied by the name, eval-after-load
runs the code after the specified file is loaded.
You can try finding a different file to trigger loading, instead of using semantic.el. (Perhaps some other file that semantic.el requires.)
If necessary, you could hook into require
:
(defadvice require (before CEDET-require activate)
(if (eq 'semantic (ad-get-arg 0))
(load "cedet")))
Although (load "cedet")
should probably be (require 'cedet)
, or you'll wind up reloading it every time. (I'm not sure if CEDET has a (provide 'cedet)
, so I didn't do it that way in my example.)
Note that putting advice on require
will not do anything if semantic has already been loaded, so you may need to check (featurep 'semantic)
first and load cedet.el immediately if necessary.