CraftedEmacs Update, Versions, and Namespaces
It's been another month, time for an update! This post will be a bit longer than others, I have a few different things to talk about:
- Crafted Emacs Update – a few PRs were merged, a few issues closed.
- Tracking development rather than using stable versions
- An interesting post on namespaces and shorthands and my thoughts on those.
Crafted Emacs
- A pull request was submitted to use the tabspaces package for managing buffers for a project. It's a neat idea, I haven't tried it out, but the concept and demo from the GitHub page look pretty neat. I have used tabs to do approximately the same thing, so I might try this new configuration and see which I like better. Check out the GitHub page though (see link above) and read about it to see if it makes sense in your workflow.
- There have been several issues with doom-modeline, mostly related to the package found on MELPA and people who use Helm. This broke a few configurations, but the solution was the same in those cases, stop using doom-modeline. I pushed a change to do just that. There is a variable to customize to enable it again.
- Another pull request added showing the eldoc for a completion when it was selected when using Corfu.
corfu-doc
as a package has been deprecated. The authors of Corfu and Corfu-Doc worked together to pull that package in as an extension to Corfu itself. The new extension name iscorfu-popupinfo
. There was an old pull request to removecorfu-doc
once the merge had occurred, however, it was from before the name change from Rational Emacs to Crafted Emacs. I pulled that request in, fixed the conflicts and name change forglobal-corfu-mode
and now everything is back up-to-date and working well. The author of that pull request even mentioned the newcorfu-popupinfo
was working very well indeed!
Versions: development vs released aka stable
I've commented on this topic before, but as it has come up again a few times recently, it seemed to be a ripe topic to talk about again.
Crafted Emacs, if you use package.el
prefers to install “stable” packages rather than development versions. Stable, in this context should really read “released” though. The name of the repository has the word “stable” in it though. The reason we prefer the stable packages is they are more likely to not break on update, and updates come (usually) a bit slower. There is no guarantee the package authors have completely tested every integration point with other packages, or that any testing at all has occurred. That statement is true of the development versions as well, they just change more frequently.
So, why bring this up again? Well, if you prefer to use straight.el
with your Crafted Emacs configuration, you risk pulling development versions which might break your configuration. This is because we don't prioritize released versions, so you get the most recent commit. Sometimes, that breaks things. This happened a couple of times with doom-modeline
this month. One suggestion I had was to install a released version. In at least one case, that solved the problem. In another case, turning off doom-modeline
worked just as well. This came up enough times, I chose to just disable doom-modeline
by default.
Thus, if you choose to use the development versions (i.e. pull directly from a source repository on the main development branch), then understand things may break in surprising ways. Possible options when this happens:
- Ensure dependencies are also up-to-date, sometimes just updating the dependencies will resolve the issue.
- Revert to a previous commit that was working for you.
- File a bug report, ideally with a patch or pull request to fix it.
- Install a released version (pull from a tag in version control).
In a bit of irony, sometimes a released version will break on update because it depends on a development version of another package that doesn't have releases. This is an unfortunate situation. If you happen to be using straight.el
you can lock that development version to a specific commit.
Namespaces and the shorthand feature in Emacs 28+
There is a very interesting post on the use of the shorthand
feature in Emacs. Andrey does a great job of describing shorthands, how they compare to other systems and the “namespace” topic in general. In my case, didn't even know shorthands were a thing, so I learned something. If you haven't read the topic in the Emacs Lisp manual (online here), take a read on it.
Emacs lisp does not have namespaces. At least not in the sense that other lisps do. It's a manual process to prefix the name of the file before all the symbols in that file to “namespace” things. For example, in the file crafted-package.el
symbols all have the prefix crafted-package-
and we get names like crafted-package-install-package
. The first bit is the “namespace”, if you will. What a shorthand does is tell the reader to substitute a shorter version (a shorthand) for the “namespace”. In this example, we could have a shorthand description of: (("cp-" . "crafted-package-"))
and then I could write cp-install-package
. Nothing changes under the hood, as a matter of fact if I place the point on the cp-
portion, the eldoc says the full name in the echo area.
I'm not sure I will be using this feature in any Crafted Emacs modules. I think it's a little clearer to just spell things out, even if that makes the name of a symbol fairly long. It's also a bit inconvenient to scroll to the bottom of the file to find the shorthand definition in the local variables comment. Imagine having several shorthands described, you'd have to jump to the bottom to see which shorthand applied to which “namespace” just to read the code. Here is the example from the manual, but consider if this were from a larger work and how confusing it could end up being if there were a few more shorthands or the file was fairly long.
(defun t-reverse-lines (s) (string-join (reverse (sns-lines s)) "\n")
;; Local Variables:
;; read-symbol-shorthands: (("t-" . "my-tricks-")
;; ("sns-" . "some-nice-string-utils-"))
;; End:
Shameless Plug
If you enjoy configuring Emacs and tweak yours often, you might consider giving Crafted Emacs a try. I'm sure you'll find some rough edges, and when you do, I invite you to open an issue, or submit a pull request. Or, maybe you won't find any rough edges and this will be just the thing you need. I'm not holding my breath on that just yet.
If you enjoy crafting your computing experience, from hacking on Emacs, your Linux/Mac/Windows configuration, maybe your Guix or NixOS home configuration, or whatever it is… consider joining the SystemCrafters community!
Tags: #emacs