News for hackers. Stuff that matters.

Ask HN: Looking for a Programable Text Editor

I’m not sure if this exists, but I’m curious what would be the closest thing available to an “Event based programmable text editor”.

Imagine this scenario:

    - Every monday at 10, the editor, would inject a checklist into your work log with some weekly checks you do at work.
        - Some of the checks are manual, some have inputs to accept extra data
        - Some are automated because you wrote a snippet of code for doing such check
        - On save, convert to json and send to someone via email
    - Every time you do this, you need to do a followup around 2days later with the person that received the checklist. They will provide a paragraph with some feedback that you need to save. To do so, your editor, already injected a form into your work log for doing so.
This is just an example but could go very far I imagine.
( 11 comments | 2 points | on HN )
Re:Ask HN: Looking for a Programable Text Editor by fungiblecog on Monday December 19, 2022 @01:51PM (#34055988)
emacs is the programmable text editor
Re:Ask HN: Looking for a Programable Text Editor by thr3ads on Monday December 19, 2022 @02:48PM (#34056717)
Because of the steep learning curve and troubleshooting associated with it, I've become more hesitant in recommending Emacs. However for the curious, the video Getting Started in Org Mode [1] which is a great demonstration on Emacs and Org Mode's potential as an organizational tool. Anyone still curious and would like to smooth out the learning curve, I'd recommend using an emacs starter kit such as Doom Emacs [2] which has a lot of OOB functionality without having to immediately learn Elisp.

[1] https://www.youtube.com/watch?v=SzA2YODtgK4

[2] https://github.com/doomemacs/doomemacs

Re:Ask HN: Looking for a Programable Text Editor by deafpolygon on Monday December 19, 2022 @03:15PM (#34057041)
It is daunting, but no more than say, a Visual Studio IDE, or learning how to use Microsoft Office (Word and Excel can be complicated as hell).

Starting with Doom Emacs would go a long way, and was what really helped me get started. Of course, it helped that I was familiar with Vim.

Re:Ask HN: Looking for a Programable Text Editor by Stin9er on Monday December 19, 2022 @01:56PM (#34056059)
Neovim with Lua should do the trick.
Re:Ask HN: Looking for a Programable Text Editor by ktpsns on Monday December 19, 2022 @02:21PM (#34056382)
Since vom and emacs were already proposed, there is a third classic in this round: Shell programming. Typically you have $EDITOR env set (to something like nano, vim, emacs, gedit, kwrite, etc) and then can include it in your script as in

   echo stuff >> worklog
   $EDITOR worklog && mailto someone
etc
Re:Ask HN: Looking for a Programable Text Editor by jmholla on Monday December 19, 2022 @02:34PM (#34056547)
If you want to handle `$EDITOR` not being set, at least in bash, you can use one of it's parameter expansion features:

    ${EDITOR:-vim}
Will use vim if `$EDITOR` is unset.
Re:Ask HN: Looking for a Programable Text Editor by deafpolygon on Monday December 19, 2022 @03:13PM (#34057022)
Emacs, Vim, a UNIX shell
Re:Ask HN: Looking for a Programable Text Editor by smcn on Monday December 19, 2022 @03:27PM (#34057188)
Just to echo a few comments, I'd use Emacs for this.

For time based events, you have the `run-at-time` function.

For snippets, I'd look at YASnippet[0] as they're really easy to create and you're granted a significant amount of control. Nothing you wrote sounds outside the scope of what it can provide.

On save is easy, just use `after-save-hook`. Emails is easy, too, though you will need SMTP or something.

Followup email may require custom code however Emacs 29 has SQLite support so you may be able to utilise that?

0: https://joaotavora.github.io/yasnippet/

Re:Ask HN: Looking for a Programable Text Editor by tracker1 on Monday December 19, 2022 @04:16PM (#34057829)
Could probably write VS Code extenions that do all this for you.
Re:Ask HN: Looking for a Programable Text Editor by MrMan on Monday December 19, 2022 @09:31PM (#34060815)
emacs is socialist and bad, Neovim is social democrat and good
Re:Ask HN: Looking for a Programable Text Editor by gwp on Monday December 19, 2022 @10:09PM (#34061062)
Acme: http://acme.cat-v.org/ It can do everything Emacs can but it's so lightweight it almost doesn't exist. Its power comes from the fact that it brings your external tools together.

It can be programmed using its filesystem (9p) interface, and extended by adding plumber(4) rules.

A demo by Russ Cox: https://youtu.be/dP1xVpMPn8M