[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pkg-autoloads.el vs. pkg-loaddefs.el
From: |
Stefan Monnier |
Subject: |
Re: pkg-autoloads.el vs. pkg-loaddefs.el |
Date: |
Sat, 18 Jan 2025 11:19:42 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> See the attached modified patch with altered docstring and a proper
> commit message.
LGTM, thank you,
Stefan
> From 2ca422a3d5ea53efec901bd7726bee6812a82b44 Mon Sep 17 00:00:00 2001
> Message-ID:
> <2ca422a3d5ea53efec901bd7726bee6812a82b44.1737212333.git.yantar92@posteo.net>
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Wed, 19 Jun 2024 16:35:56 -0400
> Subject: [PATCH] Reload <pkg>-loaddefs when replacing built-in packages with
> ELPA version
>
> * lisp/emacs-lisp/package.el (package--reload-previously-loaded): Add
> new optional argument to display a specified warning upon reloading.
> (package-activate-1): Always reload libraries when loading built-in
> packages. This avoids ELPA versions of built-in packages to be mixed
> with the built-in package autoloads.
>
> Link: https://yhetil.org/emacs-devel/87y1adrria.fsf@localhost/
> ---
> lisp/emacs-lisp/package.el | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index 3abce17a3e8..6ad3ca79541 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -837,11 +837,15 @@ package--library-stem
> (unless (equal file result)
> (throw 'done result))))))
>
> -(defun package--reload-previously-loaded (pkg-desc)
> +(defun package--reload-previously-loaded (pkg-desc &optional warn)
> "Force reimportation of files in PKG-DESC already present in
> `load-history'.
> New editions of files contain macro definitions and
> redefinitions, the overlooking of which would cause
> -byte-compilation of the new package to fail."
> +byte-compilation of the new package to fail.
> +If WARN is a string, display a warning (using WARN as a format string)
> +before reloading the files. WARN must have two %-sequences
> +corresponding to package name (a symbol) and a list of files loaded (as
> +sexps)."
> (with-demoted-errors "Error in package--load-files-for-activation: %s"
> (let* (result
> (dir (package-desc-dir pkg-desc))
> @@ -877,6 +881,10 @@ package--reload-previously-loaded
> (unless (equal (file-name-base library)
> (format "%s-autoloads" (package-desc-name
> pkg-desc)))
> (push (cons (expand-file-name library dir) recent-index)
> result))))
> + (when (and result warn)
> + (display-warning 'package
> + (format warn (package-desc-name pkg-desc)
> + (mapcar #'car result))))
> (mapc (lambda (c) (load (car c) nil t))
> (sort result (lambda (x y) (< (cdr x) (cdr y))))))))
>
> @@ -904,8 +912,11 @@ package-activate-1
> (if (listp package--quickstart-pkgs)
> ;; We're only collecting the set of packages to activate!
> (push pkg-desc package--quickstart-pkgs)
> - (when reload
> - (package--reload-previously-loaded pkg-desc))
> + (when (or reload (assq name package--builtin-versions))
> + (package--reload-previously-loaded
> + pkg-desc (unless reload
> + "Package %S is activated too late.
> +The following files have already been loaded: %S")))
> (with-demoted-errors "Error loading autoloads: %s"
> (load (package--autoloads-file-name pkg-desc) nil t)))
> ;; Add info node.
> --
> 2.47.1