Emacs like text editor in Elixir

I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and spacemacs for some time.

Previously I used VS Code, Idea, Sublime, Vim, Notepad++ (10 years ago) and I maybe something else which I forgot.

I’ve been playing with idea about writing some bare-bones editor which runs as mix application where you just clone the repository and can extend it as you wish by writing different OTP modules.

Recently, I discovered GitHub - ndreynolds/ratatouille: A TUI (terminal UI) kit for Elixir library with a simple DSL to write console applications and decided to give my idea a go.

It’s still an early stage and more like proof of concept but here it is: GitHub - achempion/alice, I hope to reach stage when it starts to be usable for simple edits.

In order to make consistent progress I decided to also try streaming development and all the issues I’m trying to figure out on twitch channel Twitch, for this year I want to stream each day at CET 8 p.m for an hour or so, would appreciate any feedback.

10 Likes

Cool project @achempion

This reminds me of this talk I’ve watched recently:

I was just thinking about it this week.

BTW: Just out of curiosity, have you benchmarked your editor against other editors? I’d love to know how viable is to create a full-fledge text editor in elixir.

2 Likes

Awesome, thanks a lot for the link, very interesting talk. Editor link from a talk doesn’t work though :smile:.

Just out of curiosity, have you benchmarked your editor against other editors?

I’d love to, but it’s still early stages where I’m trying to figure out all the boring stuff first, like how to trigger recompilation without restarting the editor, where to redirect logs, some sane DSL to write modules/extensions.

The end goal is having Emacs like operating system text editor written in Elixir which can be extended using Elixir language as well.

2 Likes

Hi achempion - I am so glad you posted this here, for I think we share a vision. I was also a heavy user of vim & emacs, always had my own large .vim_rc / init.el file, and it was a constant project to improve and maintain it. One day I had the epiphany that if I was going to spend the rest of my life hacking away on editors, then I absolutely didn’t want to be doing it in elisp/vimscript!! So about 2 years ago I began a project which I think shares a vision with your own, it’s called Flamelex, and I have a small video I just made which goes over some of the functionality I have built so far:

As you can see, I decided to proceed by basing my project on the Scenic graphics lib (ElixirConf 2018 - Introducing Scenic A Functional UI Framework - Boyd Multerer - YouTube) - Scenic is fast approaching v1.0, Boyd has put a ton of work in over the last year or so as well. It is fast & easy to work with, and capable.

The above video does a good job of showing of functionality, but I confess, it’s a choreographed demo - so far in this project’s journey, I have spent a lot of time working on low-level components and doing hacky investigation type implementations, just to learn how to attack all the problems at hand. I am now at a point where many problems have been solved in a “proof of concept” manner (not all, e.g. I want to have re-arrangable split panes, and need to introduce a layering system so I can have notifications and so the menu bars work correctly) - but my major focus for next year is going to be trying to refactor & condense this functionality down into a stable, testable, properly debugged piece of desktop software. There’s a whole bunch of extra functionality I would love to make, e.g. a git interface like magit, and a directory tree off to the side, but for now I think I am going to try and shore up some of the bugs that exist, and try to fit the code into a more cohesive general architecture.

Editing is one big part of Flamelex, but if you check out this talk I recently gave at the Denver elixir meetup (2021-12-06 Luke Taylor Introduces Memelex - YouTube) - I have actually spent the biggest chunk of my effort building the “Memex” - a personal knowledge base that’s integrated within the software. It’s analogous to org-mode, but instead of markup files it’s using a back-end which is based on the data-model used by TiddlyWiki. Check the video out for more, I’m just highlighting that this has actually been a decent chunk of work, and now that it’s more or less done, I am back to fixing up the editing experience & other parts of the app.

Personally for my money, I think writing apps in a free-form graphics package like Scenic is the way to go. You have total freedom to present things however you want, including nice curves and animations. Scenic even supports sprites, people have made some cool games in it. It’s also very fast & capable, you can see from that video that it’s very snappy and I honestly haven’t even done any optimization yet. Of course there will always be a place in this world for terminal based editors, but in my own career I am an elixir developer through and through, I try to stay away from anything that I will need to SSH in to other boxes :smiley: so having a dedicated local IDE/editor meets my needs perfectly (it’s of course not impossible to shoe-horn a shell into Flamelex, but, not yet :wink: )

It would be great to get in touch and discuss the issues, and see how we can maybe help each other :slight_smile: if you are dedicated to the terminal-based approach, there is likely still a lot of useful libraries we can share (e.g. my VimServer is only partially implemented, but it’s pure Elixir, I don’t port-out to neovim or anything). Or if you’re simply trying to calcify your vision & get the Elixir-based editor of your dreams, I would be happy to catch up on a video call or something, help you pull the repo and get it running, step you through the code etc… I’m 2 years in, so that’s a good head-start, plus open-source lives on passionate programmers who want to scratch their own itch - if this project fits your vision too, perhaps it can give you a massive head-start, and we can work together to get where we both want to go even faster !

If you want to get in touch, even just to chat about editors in general, send me a DM here or you can each me on the Elixir Slack, my handle is JediLuke and I like to hang out in #scenic

  • Luke
4 Likes

The project is awesome, I looked into it during the stream and managed to run the GUI and explore a bit the codebase.

I wasn’t able to initialize a buffer because of Timeout Error (reported on GH) and also setting MEMEX_PASSWORD_KEY got me to this error

[error] GenServer Memex.Env.PasswordManager terminating
** (stop) {:badarg, {'aead.c', 90}, 'Unknown cipher or invalid key size'}`

Overall, huge effort and very cool project, I watched the whole video and it’s very nice that you can also create reach UI applications like games with it.

1 Like

Hey achempion, cheers :smiley: it has been an on-and-off side-project for me for a while now, but about 5 months ago Scenic put out a new major release (v0.11-beta) and since then I have been working on it during all my spare-time coding hours. You managed to find a lot of bugs, I assure you there are even more of them you didn’t find :smiley: I will get to work on fixing the one you reported (thankyou so much for this!).

It was awesome to watch your stream back and see someone in real-time interacting with software I wrote, really it was quite a thrill :smiley: I will definitely check back in with you on twitch! I really like your project too, and as you saw I think we can have a lot of crossover - we have both implemented Buffer behaviours and I’m sure so much else.

Going forward, my main focus is to re-write from scratch the actual text_box component (which you found in neo_text_box.ex) and do it correctly, with new knowledge I’ve developed as I go about how to use Scenic correctly. This is a fairly complex problem when you have to implement it from scratch, and there are a few fairly distinct use-cases for one piece of code, e.g. I want to be able to support internal scrolling, resizing and wrapping of text, depending on opts that get passed in - I need to satisfy all these use cases in order to have one generic text-box component across the entire application, and it should become a re-usable component for the entire Scenic community. It should also support multi-mode (i.e. vim) editing, but that will probably come after/seperately.

Will keep you updated - keep streaming, I will check back in, and when I’ve fixed up some of these issues over the holidays maybe we can revisit it :smiley: again, was super fun for me to watch you interact with Flamelex, I learned a lot and Flamelex will benefit a lot even just from users like you trying it out and sharing feedback! Let me know when you want someone to try out alice for the first time, I will gladly return the favor :slight_smile:

3 Likes