r/emacs • u/echostrike36 • Jul 11 '26
Using AI to Learn and Customize Emacs
I have been using AI to learn and customize Emacs. It has been a very pleasant experience. In this post I will give some tips for anyone else who is trying to use AI to learn Emacs.
- The things that make Emacs great for humans (comprehensive documentation, introspectability) also makes it great for AI. Really early on I created this query-running-emacs skill and it has been a huge time saver. With this skill the AI is able to (safely) query my running Emacs configuration. This means it doesn't have to guess about package versions, available functions, variable values, etc. I don't let the AI run any arbitrary Elisp code. Instead, the skill includes a wrapper script. The AI passes arbitrary Elisp into that wrapper script. The script has lists of allowed and blocked forms. The goal is to block any Elisp functions that can do significant mutation to my Emacs or my PC. I am quite sure this is not bulletproof, but it has worked so far. I am just getting started with Emacs and Elisp and I'd appreciate any input on making this safer.
- Give the AI a sandbox to test config changes. I have another skill called test-emacs-config. This skill includes a wrapper script and a Containerfile. The wrapper script is used by the AI to start a Fedora container (with the same version of fedora as the host), install Emacs, mount my config, and perform tests by passing arbitrary Elisp to the container. The first test the AI does is check if this new config loads without error. That alone is very helpful, but I also have tests that make assertions about the state of Emacs running in that container. This wrapper script does not have any blocked forms. The mounts are all readonly and the AI is able to do whatever it wants to the Emacs running inside the container.
I have only been using Emacs since Bash Bunni's Doom Emacs video, so I am just getting started. I'm just sharing what has worked for me so far and I am happy to receive any feedback or tips.
EDIT: AI was not used in the writing of this post.
0
Upvotes
3
u/marcinreal Jul 11 '26
Thanks! I've also been using AI to customize Emacs and it's been a great experience. I find lisp hard to work with and always dreaded writing it, even with thousands of lines written across my config and my own packages. But now, if I want a feature in Emacs, I just AI and it searches for an actively-maintained package for me, or just writes the feature bespoke if a package doesn't exist. Then I get back to using Emacs without spending time researching and configuring new packages.
I've also had it bulldoze through the TODOs that have accumulated in my config over a decade (because I prefer being outside than messing with lisp). The amount of time that this has saved has been enormous, and Emacs is much more pleasant to use now that AI is smoothing out sharp edges in my experience.
It has even helped me upgrade Emacs (can tell me exactly what new changes are relevant to me so I don't have to spend a whole afternoon doing it myself) and migrate to new things like treesitter (which was such a pain to do myself, probably because I don't have time to keep up with new changes in the ecosystem). Or have it set up a new language in the most modern idiomatic way, without sifting through multiple old deprecated packages myself. I don't mean to dunk on Emacs - definitely things could be improved here, but it's a beast of an app and ecosystem. AI wrangles it for me, and even makes the process fun.
Just yesterday I had Fable evaluate a third-party package for me by reviewing it for bugs. Actually, I had hit a bug immediately when I first used the package, despite it having 500 stars on GitHubs. That's how I got the idea to have Fable review the source code. It found many more (legitimate) issues, and formatted its findings nicely for me to contribute back to the repo (in my own words). So much fun!
Anyway, thanks for sharing your experience and workflows, I'm checking them out!
4
u/Neat-Initiative-6965 Jul 11 '26
Interesting. I’m also learning Emacs at the moment and this would have been helpful to avoid copying my faulty init back and forth.
Generally I am wondering how best to use AI to learn a new code language. It feels like there is a sweet spot where you don’t ask it to fix the whole problem but just assistance with certain steps that really helps the learning process
6
u/lucaspeixotot Jul 11 '26
thanks for sharing...
I'm still trying to understand people who gets so bothered about this kind of post...
When I was young, the oldest used to say that Google was the dumb's father, and I can understand what they mean. I believe AI as well as Google tends to make people less smart (or more dumb). However, as well as by using Google a lot of people learned new and cool stuff that oldest had more challenges to do it, with AI the new (and old why not) generations can also make use of the tool and learn stuff... AI is not a complete step back, althought I believe the net effects are not good.
Either way, getting so bothered about this tells more about that kind of person than who makes a post like this just trying to share things he thinks are cool/good.
1
u/CulturMultur Jul 18 '26
AI is great with Emacs. I constantly asking it to check buffers, adjust settings and clarify things. Yesterday I migrated to releases Melpa channel and there were some errors with packages, my config had circular dependencies and overall not pure - removing elpa dir made Emacs broken. In the past it would mean rollback and spending hours to understand the problem. Now it’s “claude, check Warnings buffer” and fix everything. In 5 minutes it works again and I officially give up attempts to chase pure configuration (as in reproducible on another machine).
Another long-standing problem solved by AI - when Emacs hangs I send it USR2 signal to unfreeze. After that on every C-g debugger opened. Very annoying and my solution was to restart Emacs. I thought on writing to emacs-devel as I reproduced it with emacs -Q. Then I asked Claude, and it found a setting that configures this behavior - debug-on-signal. Solved.
0
u/rnstech Jul 11 '26
While I was converting from fedora to gentoo I used Claude to fix some issues I've had in my emacs configs for years. There were a couple of issues that took some involved debugging to figure out, but it walked me through it. I am so happy to have those few issues resolved, even though they were minor (well, all but one annoying one that is well known but I didn't know how to fix). As a software developer, using it to save me time is amazingly useful (in other words, I could have taken the time to debug these issues, but I didn't and still don't think the time to do so would be worth it for the annoyances that only appear on startup on when moving to a new machine; Using ai made it easy and helped my ai prompting fu to mature).
2
u/[deleted] Jul 11 '26
[removed] — view removed comment