diff options
| author | Lars Ingebrigtsen | 2022-06-16 13:49:02 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-06-16 13:49:11 +0200 |
| commit | feb654b4605cd84d1913d33a7d4c687bd4e71be7 (patch) | |
| tree | 2dd9d119cc78bae5b419f5e7556a7421d4452819 | |
| parent | 217c41c7b07b10d5a93f4cf7b6619db411603e65 (diff) | |
| download | emacs-feb654b4605cd84d1913d33a7d4c687bd4e71be7.tar.gz 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).
| -rw-r--r-- | doc/emacs/package.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 28 |
3 files changed, 43 insertions, 0 deletions
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi index eb4f5b0edab..2eb12e096a9 100644 --- a/doc/emacs/package.texi +++ b/doc/emacs/package.texi | |||
| @@ -483,6 +483,16 @@ The default value is just @code{'(all)}. | |||
| 483 | installed will be ignored. The @samp{muse} package will be listed in | 483 | installed will be ignored. The @samp{muse} package will be listed in |
| 484 | the package menu with the @samp{held} status. | 484 | the package menu with the @samp{held} status. |
| 485 | 485 | ||
| 486 | @findex package-recompile | ||
| 487 | @findex package-recompile-all | ||
| 488 | Emacs byte code is quite stable, but it's possible for byte code to | ||
| 489 | become outdated, or for the compiled files to rely on macros that have | ||
| 490 | changed in new versions of Emacs. You can use the @kbd{M-x | ||
| 491 | package-recompile} command to recompile a particular package, or | ||
| 492 | @kbd{M-x package-recompile-all} to rebuild all the packages. (The | ||
| 493 | latter command might take quite a while to run if you have many | ||
| 494 | installed packages.) | ||
| 495 | |||
| 486 | @node Package Files | 496 | @node Package Files |
| 487 | @section Package Files and Directory Layout | 497 | @section Package Files and Directory Layout |
| 488 | @cindex package directory | 498 | @cindex package directory |
| @@ -983,6 +983,11 @@ list-packages'. | |||
| 983 | This command allows updating all packages without any queries. | 983 | This command allows updating all packages without any queries. |
| 984 | 984 | ||
| 985 | +++ | 985 | +++ |
| 986 | *** New commands 'package-recompile' and 'package-recompile-all'. | ||
| 987 | These commands can be useful if the .elc files are out of date | ||
| 988 | (invalid byte code and macros). | ||
| 989 | |||
| 990 | +++ | ||
| 986 | *** New DWIM action on 'x' in "*Packages*" buffer. | 991 | *** New DWIM action on 'x' in "*Packages*" buffer. |
| 987 | If no packages are marked, 'x' will install the package under point if | 992 | If no packages are marked, 'x' will install the package under point if |
| 988 | it isn't already, and remove it if it is installed. | 993 | it isn't already, and remove it if it is installed. |
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." | |||
| 2423 | (package-install pkg 'dont-select)) | 2423 | (package-install pkg 'dont-select)) |
| 2424 | 2424 | ||
| 2425 | ;;;###autoload | 2425 | ;;;###autoload |
| 2426 | (defun package-recompile (pkg) | ||
| 2427 | "Byte-compile package PKG again. | ||
| 2428 | PKG should be either a symbol, the package name, or a `package-desc' | ||
| 2429 | object." | ||
| 2430 | (interactive (list (intern (completing-read | ||
| 2431 | "Recompile package: " | ||
| 2432 | (mapcar #'symbol-name | ||
| 2433 | (mapcar #'car package-alist)))))) | ||
| 2434 | (let ((pkg-desc (if (package-desc-p pkg) | ||
| 2435 | pkg | ||
| 2436 | (cadr (assq pkg package-alist))))) | ||
| 2437 | ;; Delete the old .elc files to ensure that we don't inadvertently | ||
| 2438 | ;; load them (in case they contain byte code/macros that are now | ||
| 2439 | ;; invalid). | ||
| 2440 | (dolist (elc (directory-files (package-desc-dir pkg-desc) t "\\.elc\\'")) | ||
| 2441 | (delete-file elc)) | ||
| 2442 | (package--compile pkg-desc))) | ||
| 2443 | |||
| 2444 | ;;;###autoload | ||
| 2445 | (defun package-recompile-all () | ||
| 2446 | "Byte-compile all installed packages. | ||
| 2447 | This is meant to be used only in the case the byte-compiled files | ||
| 2448 | are invalid due to changed byte-code, macros or the like." | ||
| 2449 | (interactive) | ||
| 2450 | (pcase-dolist (`(_ ,pkg-desc) package-alist) | ||
| 2451 | (package-recompile pkg-desc))) | ||
| 2452 | |||
| 2453 | ;;;###autoload | ||
| 2426 | (defun package-autoremove () | 2454 | (defun package-autoremove () |
| 2427 | "Remove packages that are no longer needed. | 2455 | "Remove packages that are no longer needed. |
| 2428 | 2456 | ||