Crafted Emacs Update – March 2025
Emacs 30.1 released… and stuff broke.
Well, it's been over a year since I posted an update about Crafted Emacs! How time flies, right! I continue to support the project and have been thinking about different things to do with Crafted Emacs, but nothing really sticks as something that needs to be done.
Lost package-selected-packages
value!!
However, with the release of Emacs 30.1, there are a few things I need
to review. One thing kinda broke configurations depending on how you
write your configuration. The new “feature” from Emacs has to do with
the function that saves the values of defcustom
variables. We make
a call to the package--save-selected-packages
by adding it to the
after-init-hook
. Notice there are two dash characters in the name.
That generally means it is not a “public” API, and using it can be
risky. Basically, the form of that function is this:
(defun package--save-selected-packages (&optional value) ... )
Notice the &optional value
parameter? In Emacs version prior to
30.1 if that value was not present (ie its value is nil
) it would
use whatever the value of the package-selected-packages
variable,
which is a list of the packages to be installed. We update that value
by calling add-to-list
to append the packages to install, which is
important essentially the first time you startup Emacs from your
configuration. After that, they are already installed, so the value
is checked and if there is nothing to do, no additional packages are
installed. In Emacs prior to version 30.1, this was safe since we
were already updating the value and the &optional value
parameter
would not be used if it were nil
.
All that changes with Emacs 30.1 which resulted in something that looked like this:
(custom-set-variables
...
'(package-selected-packages nil)
...)
That's a bit concerning as we need to check if all the packages are
installed already, but the value is nil
when we start Emacs
(assuming you follow the pattern in the example configurations and
load the custom.el
file at the top of your init.el
file). It is
updated during initialization, but then written back out as nil
after initialization.
That happens because the new code for that function checks to see if
either the optional value is not nil
or the value of
after-init-time
is set. When after-init-time
is set, then the
assumption is the provided (or possibly not provided) value
parameter contains the list of installed packages and it gets sorted
and set as the list package-selected-packages
. Since we weren't
providing that optional value, the result was the
package-selected-packages
was always nil
. I had noticed this
behavior and just thought it was something wrong with my
configuration, but then Jabbo (one of the Crafted Emacs maintainers)
raised a bug about it and provided a PR to solve the problem. The
solution is to pass the package-selected-packages
along as the (not
so) &optional value
.
Oh, and by the way…
We also added code for using the new preview completion function
globally. David demonstrated it in a recent live stream. This
configuration lives in the crafted-defaults-config
module and gets
turned off if you use the crafted-completion-config
module with
Corfu installed.
In other news…
There was an issue raised about tree sitter, upstream broke a few
things like latex
, janet
, and markdown
for different reasons.
Jvdydev provided some guidance on how to work around the problem. We
use the treesit-auto
package to help automate the installation of
grammars, and usage is by opt-in for the specific grammars you would
actually use. If you ran into the problem from the issue, you could
remove those from the list of grammars, and possibly try to install
them manually or use the Emacs built-in functions to install them. My
comment on that issue has an example installing the grammars for tsx
and typescript
. As the problem is outside the scope of Crafted
Emacs (ie we depend on the author of the treesit-auto
package to fix
issues), there isn't much we can do, but, as you can see in the
comments, we do try to be as helpful as possible.
A similar kind of problem was raised regarding org-appear
and org
version 9.7.2
. The built-in version of org
in Emacs prior to
version 30.1 is 9.6.15
and the problem mentioned does not appear
with that version. This is another situation where the problem is
outside the scope of Crafted Emacs. I'll test again with Emacs 30.1
which includes org 9.7.11
and see if the problem persists and make
an update to this blog with what I find.
[UPDATE] I could not duplicate the problem above as mentioned in this issue.
Finally, there was an issue that raised a question about setting the
value of the package-archives
based on the running Emacs version.
The question was very well answered by Jvdydev but it turns out the
question was actually about the inability to install emark-consult
.
Jvdydev provided an answer to that as well, at least as best as she
could without an error message.
Conclusion
So, it's been slow on the Crafted Emacs front so far, but if you are using Crafted Emacs and notice anything a bit odd after the update to Emacs 30.1, please post an issue and we'll be happy to take look and either fix something in our code or possibly help you with your configuration. Of course, you can always submit a PR with your issue as well, we'd be happy to review it and possibly pull it in.
Happy Crafting!
Tags: #emacs