from Hacker News

Ask HN: Looking for a Programable Text Editor

by xcubic on 12/19/22, 6:30 PM with 11 comments

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.
  • by smcn on 12/19/22, 8:27 PM

    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/

  • by ktpsns on 12/19/22, 7:21 PM

    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
  • by gwp on 12/20/22, 3:09 AM

    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

  • by fungiblecog on 12/19/22, 6:51 PM

    emacs is the programmable text editor
  • by Stin9er on 12/19/22, 6:56 PM

    Neovim with Lua should do the trick.
  • by tracker1 on 12/19/22, 9:16 PM

    Could probably write VS Code extenions that do all this for you.
  • by deafpolygon on 12/19/22, 8:13 PM

    Emacs, Vim, a UNIX shell
  • by MrMan on 12/20/22, 2:31 AM

    emacs is socialist and bad, Neovim is social democrat and good