ITADN

What does the Emacs 30 stub mean in practice?

#67Closedmeedstrom 创建于 2025-03-04
M
meedstromcommented
Quoting the NEWS file for Emacs 30: ``` ** New package Compat. Emacs now comes with a stub implementation of the forwards-compatibility Compat package from GNU ELPA. This allows built-in packages to use the library more effectively, and helps preventing the installation of Compat if unnecessary. ``` I'm not at all clear on what this "stub implementation" means for me as a package developer. (The wording of that NEWS mainly raises questions.) Be wonderful if someone can help clarify for me! ## Question 1 Let's say it is the future, Emacs 32.1 is out. Then say I'm still running Emacs 30.1, and do not install Compat. Then I load some lisp that includes a call to `(require 'compat)`, intending to use some Emacs 31/32 stuff. What happens? 1. Would compat-32.el already have been backported into Emacs 30.x, so that it's expected to exist on disk? 2. Does it try to pull compat from the internet? (the word "stub" brings this to mind) 3. Does the lisp just hit an error because the Emacs 31/32 stuff is absent? ## Question 2 Quoting the compat manual at this time of writing (emphasis mine): > A minimal version of Compat will be present in Emacs version 30 and newer. Packages which are part of Emacs itself and want to take advantage of Compat, can also use (require 'compat). The advantage of the inclusion of a minimal Compat in Emacs is that Compat will not be installed **if you require a version newer or equal than** the current Emacs version. For example, if a package depending on Emacs 25.1 and Compat 29.1 is installed on Emacs 30.1, Compat will not be pulled in as dependency, since Emacs 30.1 already provides the required functionality. First aside, maybe the bolded part is meant to say: "if you require a version of Compat older than the installed Emacs version" Second aside, how do I know which version of Compat that exists in Emacs 30.1? If I understand correctly, 30.0.1.x is for 30.1, so if if I have the following `Package-Requires` statement: ;; Package-Requires: ((emacs "28.1") (compat "30.0.2.0")) then an user of Emacs 30.1 installing my package would always pull a new compat from ELPA, since 30.0.2.0 would not be built in. So it would be more advantageous to leave it at: ;; Package-Requires: ((emacs "28.1") (compat "30.0.1.0")) Anyway, I'm not seeing how it could help a built-in package, since by the time a package is included into, say, Emacs 31, the latest version of Compat in existence is also 31, so it would always be a stub. Is it just so that packages like Transient, which are also distributed outside Emacs, don't need to remove the `(require 'compat)` call every time they push a commit to source control? But they could just have a separate branch, but that's as far as my imagination got me for now.
关闭于 2025-03-04 12 条评论