installed will be ignored. The @samp{muse} package will be listed in
the package menu with the @samp{held} status.
+@findex package-recompile
+@findex package-recompile-all
+ Emacs byte code is quite stable, but it's possible for byte code to
+become outdated, or for the compiled files to rely on macros that have
+changed in new versions of Emacs. You can use the @kbd{M-x
+package-recompile} command to recompile a particular package, or
+@kbd{M-x package-recompile-all} to rebuild all the packages. (The
+latter command might take quite a while to run if you have many
+installed packages.)
+
@node Package Files
@section Package Files and Directory Layout
@cindex package directory
*** New command 'package-update-all'.
This command allows updating all packages without any queries.
++++
+*** New commands 'package-recompile' and 'package-recompile-all'.
+These commands can be useful if the .elc files are out of date
+(invalid byte code and macros).
+
+++
*** New DWIM action on 'x' in "*Packages*" buffer.
If no packages are marked, 'x' will install the package under point if
'force 'nosave)
(package-install pkg 'dont-select))
+;;;###autoload
+(defun package-recompile (pkg)
+ "Byte-compile package PKG again.
+PKG should be either a symbol, the package name, or a `package-desc'
+object."
+ (interactive (list (intern (completing-read
+ "Recompile package: "
+ (mapcar #'symbol-name
+ (mapcar #'car package-alist))))))
+ (let ((pkg-desc (if (package-desc-p pkg)
+ pkg
+ (cadr (assq pkg package-alist)))))
+ ;; Delete the old .elc files to ensure that we don't inadvertently
+ ;; load them (in case they contain byte code/macros that are now
+ ;; invalid).
+ (dolist (elc (directory-files (package-desc-dir pkg-desc) t "\\.elc\\'"))
+ (delete-file elc))
+ (package--compile pkg-desc)))
+
+;;;###autoload
+(defun package-recompile-all ()
+ "Byte-compile all installed packages.
+This is meant to be used only in the case the byte-compiled files
+are invalid due to changed byte-code, macros or the like."
+ (interactive)
+ (pcase-dolist (`(_ ,pkg-desc) package-alist)
+ (package-recompile pkg-desc)))
+
;;;###autoload
(defun package-autoremove ()
"Remove packages that are no longer needed.