emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PACKAGE-FEATURES, and hot update of Emacs packages


From: Phil Sainty
Subject: Re: PACKAGE-FEATURES, and hot update of Emacs packages
Date: Sun, 28 Nov 2021 01:16:22 +1300
User-agent: Orcon Webmail

On 2021-11-27 22:31, Qiantan Hong wrote:
Then to really update p, one just need to

(mapc (lambda (feature) (unload-feature feature t)) (package-features p))
(package-reinstall p)
(require p)

Unloading a feature will trash the user's configuration, and so when
you load the updated library only the default config will be set --
unless the user used `eval-after-load' (which certainly can't be
assumed).  As such, I don't think that could work as a reliable "hot
update" process.

My approach to this general issue (in libraries I've written) has been
to detect at load time if the user had an older version of the library
loaded, and to perform any appropriate in-place upgrades.  E.g.:
https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/so-long.el?id=aebba085cba1#n2012

This does require that the code knows both the previously-loaded and
newly-loaded version numbers, which can be tricky if the previous
version of the code wasn't storing its version; so I think it would be
great if Emacs *automatically* tracked this information for packages
(or any library that supplies a version) so that authors could write
such update code without needing to have previously prepared for it.

I don't think this currently happens.  I can see the functions
`package-get-version' and `package-desc-version' (which can be used
with `package-alist'), but haven't spotted anything which is storing
the version of a package that is/was loaded (and I don't think this
information is as easily accessible when loading byte-compiled files,
as version comments don't appear in the .elc file).

I suppose (package-desc-version (package-load-descriptor DIR)) can be
used for ELPA packages installed in the standard way, so maybe there's
scope for using that; but I suspect that'd be too brittle an approach,
as there are many non-standard ways of loading things.


-Phil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]