Need help to send a BLAH RET to an eat buffer from Lisp #17

Closed
opened 2022-12-06 01:41:11 +00:00 by edrx · 4 comments

Hi, I am trying to make eepitch[0] support eat, and I need help with something that I'm not being able to figure out from the source code...

Suppose that I have a buffer called "eat: lua5.1 (2)" - let me call it the "target buffer" - that is in eat-mode and in eat-emacs-mode, and that is running lua5.1. What is the right way to "send the line BLAH and a RET" to it? Let me make this more precise: I need to simulate that the user went to the target buffer, switched it to some non-read-only eat mode, typed "BLAH" there, typed a RET after that BLAH, and switched back to eat-emacs-mode. How do I do that? For example, in vterm I can do this:

(vterm-send-string "BLAH")
(vterm-send-return)

I don't know how much detail I should send, so let me guess that it is better to send a lot... here it goes, for the sake of completeness. There is more info about eepitch here,

[0] http://angg.twu.net/eepitch.html

the functions in eepitch that support vterm are here,

[1] http://angg.twu.net/eev-current/eepitch.el.html#other-terms

and a solution that is simple but fragile is ok for me. For example, we can suppose that the "cursor of the terminal" is at (point-max). More info: I am on Debian and running an Emacs 29 compiled today, and my code for creating the buffer "eat: lua5.1 (2)" is here:

(defun ee-split (str)
  (if (stringp str)
      (split-string str "[ \t\n]+")
    str))

(defun ee-unsplit (list)
  (if (listp list)
      (mapconcat 'identity list " ")
    list))

(defun find-eatprocess0 (name program-and-args)
  (let* ((bufname (format "*%s*" name))
         (buffer  (switch-to-buffer bufname)))
    (unless (eq major-mode #'eat-mode)
      (eat-mode))
    (unless eat--process
      (eat-exec buffer "eat" "/usr/bin/env" nil program-and-args))
    (eat-emacs-mode)))

(defun find-eatprocess (program-and-args &optional n)
  (find-eatprocess0
   (format "eat: %s%s"
	   (ee-unsplit program-and-args)
	   (if n (format " (%s)" n) ""))
   (ee-split program-and-args)))
Hi, I am trying to make eepitch[0] support eat, and I need help with something that I'm not being able to figure out from the source code... Suppose that I have a buffer called "*eat: lua5.1 (2)*" - let me call it the "target buffer" - that is in eat-mode and in eat-emacs-mode, and that is running lua5.1. What is the right way to "send the line BLAH and a RET" to it? Let me make this more precise: I need to simulate that the user went to the target buffer, switched it to some non-read-only eat mode, typed "BLAH" there, typed a RET after that BLAH, and switched back to eat-emacs-mode. How do I do that? For example, in vterm I can do this: ``` (vterm-send-string "BLAH") (vterm-send-return) ``` I don't know how much detail I should send, so let me guess that it is better to send a lot... here it goes, for the sake of completeness. There is more info about eepitch here, [0] http://angg.twu.net/eepitch.html the functions in eepitch that support vterm are here, [1] http://angg.twu.net/eev-current/eepitch.el.html#other-terms and a solution that is simple but fragile is ok for me. For example, we can suppose that the "cursor of the terminal" is at (point-max). More info: I am on Debian and running an Emacs 29 compiled today, and my code for creating the buffer "*eat: lua5.1 (2)*" is here: ``` (defun ee-split (str) (if (stringp str) (split-string str "[ \t\n]+") str)) (defun ee-unsplit (list) (if (listp list) (mapconcat 'identity list " ") list)) (defun find-eatprocess0 (name program-and-args) (let* ((bufname (format "*%s*" name)) (buffer (switch-to-buffer bufname))) (unless (eq major-mode #'eat-mode) (eat-mode)) (unless eat--process (eat-exec buffer "eat" "/usr/bin/env" nil program-and-args)) (eat-emacs-mode))) (defun find-eatprocess (program-and-args &optional n) (find-eatprocess0 (format "eat: %s%s" (ee-unsplit program-and-args) (if n (format " (%s)" n) "")) (ee-split program-and-args))) ```
akib added the
Kind: Question
label 2022-12-06 04:18:42 +00:00
Owner

For now do (process-send-string eat--process "blah\n") in the terminal buffer. I'll create a function for this when Eat matures.

For now do `(process-send-string eat--process "blah\n")` in the terminal buffer. I'll create a function for this when Eat matures.
akib closed this issue 2022-12-06 04:22:02 +00:00

Hi akib, has there been any progress on this, it complains about eat--process being void variable when I use it like this:

(eat--send-string eat--process "\n")
Hi akib, has there been any progress on this, it complains about `eat--process` being void variable when I use it like this: ```lisp (eat--send-string eat--process "\n") ```
Owner

The API has changed. It's now (eat-term-send-string TERMINAL STRING).

The API has changed. It's now `(eat-term-send-string TERMINAL STRING)`.

And what would the TERMINAL argument here be, can you share example usage?
Where I want to send multiple strings to same eat terminal, how would I choose that terminal?

And what would the TERMINAL argument here be, can you share example usage? Where I want to send multiple strings to same eat terminal, how would I choose that terminal?
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: akib/emacs-eat#17
No description provided.