diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-06-16 13:49:02 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-06-16 13:49:11 +0200 |
commit | feb654b4605cd84d1913d33a7d4c687bd4e71be7 (patch) | |
tree | 2dd9d119cc78bae5b419f5e7556a7421d4452819 /lisp/emacs-lisp | |
parent | 217c41c7b07b10d5a93f4cf7b6619db411603e65 (diff) | |
download | emacs-feb654b4605cd84d1913d33a7d4c687bd4e71be7.tar.gz emacs-feb654b4605cd84d1913d33a7d4c687bd4e71be7.tar.bz2 emacs-feb654b4605cd84d1913d33a7d4c687bd4e71be7.zip |
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).
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/package.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 9aaeb052d0d..ef46bd3a278 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2423,6 +2423,34 @@ object." (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. |