1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 14:30:50 -08:00

Add new package.el commands for recompilation

* doc/emacs/package.texi (Package Installation): Document them.

* lisp/emacs-lisp/package.el (package-recompile):
(package-recompile-all): New commands (bug#27253).
This commit is contained in:
Lars Ingebrigtsen 2022-06-16 13:49:02 +02:00
parent 217c41c7b0
commit feb654b460
3 changed files with 43 additions and 0 deletions

View file

@ -2422,6 +2422,34 @@ object."
'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.