13

Sometimes I want to call unload-feature to unload a library… and it a library depends on it… and another library depends on that library…

How can I unload a library and all the libraries that depends on it, without walking through the dependency tree manually?

A common use case is to unload all the libraries of a package (e.g. when upgrading or uninstalling), so if there's a way to do that, it would be good enough.

1 Answers1

3

There's no built-in way to do this--see Unloading in the Elisp manual.

unload-feature takes a force argument that allows forcibly unloading P even if other packages depend on P; is that sufficient for your needs?

If not, you can try to create a recursive version of unload-feature containing:

(let* ((file (feature-file feature))
       (dependents (delete file (copy-sequence (file-dependents file))))) 
  (when dependents
    (mapc #'unload-feature-recursive (mapcan #'file-provides dependents))))
Tianxiang Xiong
  • 3,848
  • 16
  • 27