[Top][All Lists]

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

PACKAGE-FEATURES, and hot update of Emacs packages

From: Qiantan Hong
Subject: PACKAGE-FEATURES, and hot update of Emacs packages
Date: Sat, 27 Nov 2021 09:31:10 +0000

package-reinstall seems to update the external UNIX file system only,
and don’t update the package loaded in the Elisp image properly.
I didn’t find a built-in way to do so, which sucks because one need
to restart Emacs (and lost the image state) to update packages.

It turns out that Emacs seems to have almost all the necessary facility
to make hot update happens, the only missing one
seems to be package-features (that finds out features loaded from the package).
Then to really update p, one just need to

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

(assuming p is the same as the “entry” feature of the whole package)

Currently I use an adhoc version
(defun package-features (p)
   (lambda (feature)
     (s-prefix-p (symbol-name p) (symbol-name feature)))

It works pretty well, I’m able to update all of my everyday packages 
which shows that hot update is very doable. Now for the rare case
that the default behavior result in inconsistent state, package maintainer
can always define feature-UNLOAD-FUNCTION to make it work nicely.

Now back to the only missing pieces, how much effort it’d take to have
a proper PACKAGE-FEATURES? Is it good to have it in core? 
(I suppose it’d be a minor change to package.el).


reply via email to

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