Got my nanochat mode for Emacs working :)

Elisp has surprisingly good network socket support...but creating a new mode involved reading some very s p a r s e documentation

Ideally, I'd have a mode that uses an "input line" at the bottom, and "text lines" above it. But I couldn't figure it out, so I just output to the buffer and enter commands using the minibuffer

https://patpatpat.xyz/data/emacs/nanochat.el

#emacs #nanochat

@mostlypat
I don't know how good the docs are but you could try making a derived mode based on comint-mode!

@vanni Ah, that's a good idea actually! I am using a derived mode of nil currently (is it still a derived mode if the parent is nil?)

The issue I found with comint-mode is that it seems to only work with external programs, but my stuff is written entirely in elisp

(Also docs are non-existent for comint, they seem to only reference it in relation to shell-mode)

@mostlypat
Ah, right. But if I'm not mistaken, you can "fake" the command if you are taking things from the network. There was an article about something similar from a few years ago, but I can't seem to find it.
If it still doesn't work out, I'd derive from special-mode and selectively make the end of the buffer editable, then update the buffer as needed (might need to temporarily make the part of the buffer above the prompt editable).
If anything, it would make it easier to provide a prompt directly inside the buffer without messing everything up (and special-mode has some useful keybinds by default). :)
@vanni @mostlypat Good news, @xenodium explored how to make "shell" modes for e.g. chat in the past years, resulting in packages like shell-maker to make this easier:
https://github.com/xenodium/shell-maker
GitHub - xenodium/shell-maker: Create Emacs shells backed by either local or cloud services.

Create Emacs shells backed by either local or cloud services. - xenodium/shell-maker

GitHub