From time to time you might run into issues with packages that are not properly
byte-compiled when installed via
association). This may manifest itself in many different ways - typically
nil/undefined when it shouldn’t be. Here’s a small utility
that might help you in such situations:
(defun er-reinstall-package (pkg) (unload-feature pkg) (package-reinstall pkg) (require pkg))
I hope you’ll agree that the function’s definition is pretty self-explanatory. Now you can do things like:
;; try running this code in ielm or a scratch buffer (er-reinstall-package 'crux) (er-reinstall-package 'projectile)
As one reader suggested we can make the function a bit more user friendly by making it an interactive command that you can
(defun er-reinstall-package (pkg) (interactive (list (intern (completing-read "Reinstall package: " (mapcar #'car package-alist))))) (unload-feature pkg) (package-reinstall pkg) (require pkg))
Now you’ll also get prompted for the package to reinstall with some convenient completion.
I assume that’s not a function you’d need often, but it might come in handy from time to time. That’s all I have for you today. Keep hacking!