开发者

Emacs Lisp: How to, an interactive buffer with REPL?

Imagine the dunnet.el game, the eliza doctor or the IELM mode...; This is, evaluating answers and prompting new questions on the main buffer, then making some actions according to their elisp rules.

I would to create something like an interactive assistant, BUT NOT prompting from minibuffer as (interactive) does (not doing M-x)... I need a kind of REPL loop. So the question i how to get interaction on the working buffer (the main screen), like any text conversational/adventure, but for call my defun'ed functions on this way.

So i need a basic elisp skeleton, to make a custom REPL. The target 开发者_开发技巧is to make an assistant with a natural language, then parsing the anwsers, and making some actions according the rules.

Thank you for your time,

Steve,


Check out ielm, which is an elisp repl included with emacs.


Depending on what can go on in your buffer, can you just give it a major mode with an appropriate re-binding of return? (This answer vaguely inspired by Lisp-Interaction-Mode's C-j)


You should bind all keys that use for moving in buffer like C-p C-n, Up Down Arrows/ page up/down just bind them to (lambda ()). change function for C-b and C-f (Left Right Arrows) if cursor position is in beginning or end of the line. And bind Return key to function that read current line from end to optional prompt (you can use Regex to remove the prompt) do whatever you want with that string, and then go to the next line in the buffer and print your result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜