reddit / emacs
Extension ideas to get better at elisp?
EternalMigrainity · 2022-06-06 22:08
Hello everyone, this is my first time posting here.
I've been using emacs for months now and I still don't have any external packages installed, primarily because what I do in emacs doesn't demand any external packages. I don't have much going on for me as a programmer or a person to need to install those packages.
I'm just a high school sophomore that likes working on my own codebases and taking notes with org mode here and there, for my codebases I use rgrep for searching terms, hs-minor-mode for code block visibility, and `M-/` for term completion, these are of course all built-in features and I consider them sufficient.
Even if I did reach a point where I did need to use external extensibility, my first resort wouldn't be using an external package, I'd honestly rather write the extension myself so I could get to expand my elisp knowledge. In my case, using external packages feels like I'm cheating the emacs experience and defeating some sort of deeper purpose.
Let me just remind you again that I don't have much going on for me as a sophomore, I don't have a professional life so there is no pressure for me to use any external packages in order to crunch time, right now my area of work is pretty limited, I'm just goofing around, I have all the freedom and time in the world to take this as an opportunity to expand my knowledge,
So when I talk about writing extensions myself, I'm not talking about writing personal replacements for huge MELPA packages that have hundreds of hours of work like AUCTeX, I don't use LaTeX, so there's no demand for me to use a huge package like AUCTeX or even consider writing a personal replacement. I hope you understand what I'm trying to convey.
The only notable things I've made with elisp that are of use to me so far are:
1. An interactive function that lets me compile my C++ programs inside of emacs, also let's me choose a wide variety of compile options from within a mini buffer.
2. When I first started out with emacs, I wanted emacs to open up the last file I was working on in a previous emacs session, so I wrote a personal package that allowed you to mark all the files you wanted to load in your next session after exiting/restarting emacs, it would also position your cursor where you left it in the last session, Only months later did I discover recentf-mode, save-place-mode, and desktop-save.
3. Tor search queries within the prompt
4. An interactive extension where I can write the contents of an HTML paragraph in a separate temporary buffer and save it to the HTML file seamlessly, I don't like writing my paragraphs in the same HTML file, I'm going to integrate this as a minor mode sometime later.
So, any extension/project ideas? Can you describe any extensions you wrote during your emacs journey that I could try rewriting? I wanna be somewhat proficient in elisp by the end of the year.
takeonrules · 2022-06-06 22:49
For option 1, spend time looking at Transient. That has the "bones" of what you are looking to build. You need to bring quite a bit, but reading through and implementing my own "menus" was a great exercise.
Transient is the package which magit further extends.
abir_valg2718 · 2022-06-07 00:26
> So, any extension/project ideas?
A broader version of [Shackle](https://depp.brause.cc/shackle/) would be neat. Basically, a wrapper for controlling display-buffer-alist in a neat way with lots of options. Plus extra controls for how to treat pop up buffers when you press q or when you close the window.
You know, sort of "one package to rule them all" with regards to pop ups.
Kodiologist · 2022-06-07 00:35
Writing a game is always amusing, and tends to demand a lot of a programming language's features, so that's a good way to give yourself a trial by fire in a programming language.
LemonBreezes · 2022-06-07 01:08
Honestly, even just a cool eye-candy package like https://github.com/wiz21b/FlamesOfFreedom, https://github.com/alphapapa/snow.el, or https://github.com/johanvts/emacs-fireplace would be super cool. I love those packages.
TheFrenchPoulp · 2022-06-07 06:47
While that could prove an effective exercise to practice and learn, I'd rather remind people that each of `shackle` and `popper`'s scopes are limited on purpose, not to have *one package to rule them all* which will become harder to maintain and/or to customize
TheFrenchPoulp · 2022-06-07 06:54
Since like many I started to work remotely a lot more often, I would often use `arecord -vvv -f dat /dev/null` to debug my sound input. It also makes it a lot more noticeable when I'm speaking with a muted microphone. I always wondered how practical it could be to have that as a segment in my mode-line, and more importantly: how reliable performance-wise
JibStyle209 · 2022-06-07 07:08
How you like shackle? I heard it is popular.
But yeah writing a layer over display-buffer-alist sounds like good idea. It’s on my todo list, I want to integrate it with ace-window and also mouse.
JibStyle209 · 2022-06-07 07:12
That’s great you want to learn more, good investment. Plus many 3rd party packages are bloated beyond your needs.
If you like messing with keybindings and modes, write a minor mode that lets you interactively and persistently bind key sequences to commands.
wasamasa · 2022-06-07 07:14
The most annoying part of writing shackle was edebug breaking on me because it relies on window management to not be broken. I had to use `M-:` a lot to reset/restore the state of `display-buffer-alist`. Generally, writing packages can teach you unexpected bits of Emacs trivia.
tonyaldon · 2022-06-07 08:57
I wrote some articles about Emacs and specifically the implementation with emacs-lisp of the feature described (available as an org-mode document or in Reddit):
[https://github.com/tonyaldon/posts](https://github.com/tonyaldon/posts)
You might found this article (part of the posts) interesting (Programming with Elisp is magic):
[https://www.reddit.com/r/emacs/comments/u9e9r3/programming\_with\_elisp\_is\_magic/](https://www.reddit.com/r/emacs/comments/u9e9r3/programming_with_elisp_is_magic/)
Last year (March 15, 2021) I also wrote down the evolution of my emacs journey so far:
[https://github.com/tonyaldon/emacs.d/blob/master/setup-history.org](https://github.com/tonyaldon/emacs.d/blob/master/setup-history.org)
You can read in that document the first commands I wrote (really not well written but they did the work when I needed them).
You can also read the files `lisp/subr.el` and `lisp/simple.el` in the emacs repository:
git clone git://git.sv.gnu.org/emacs.git
I hope this is helpful, Have a nice day, Tony ;)
00-11 · 2022-06-07 14:57
> I'm just goofing around, I have all the freedom and time in the world to take this as an opportunity to expand my knowledge
Fantastic. Just keep doing what you're doing. Nothing better than goofing around with Emacs and Elisp.
My suggestion:
When you use this or that bit of Emacs, you can no doubt envision some improvement or experimental change, no matter how slight or perhaps ill-conceived. That's the game: imagine variants.
*Try to make such a change, to a local copy of relevant bits of the original code.*
Playing with existing code this way helps you learn, besides being fun and challenging. And much of the standard Elisp code that's part of Emacs is well-written.
This way, you can bite off just as much as you want to try chewing at one time. Yet the depths you can reach are pretty much unlimited.
As you're trying to actually do something particular, you can't help but learn more - you can't avoid it.
You'll find out why the code is the way it is, and whether that's right/good or wrong/could-be-improved. You'll find out whether you've found a bug (and a possible fix) or you've come up with a new feature or other improvement.
Be forewarned, however: This is the gateway to a lifetime of twiddling, fiddling, and digging into Lisp and Emacs.