The maplev emacs mode provides a means to communicate to the tty (command-line) maple process. Alas, the method is rather crude; I designed it that way because it was all I knew how to do. However, I would really like to improve it; I'm looking for advice.
The communication is via pipes. The problem is determining when Maple's output has concluded. Ideally I'd be able to detect the prompt in the output stream, however, the prompt never appears until after the next input is sent. For example, assume I send `1+2' to the process. What I'd like to get back is `1+2\n3\n> ', that is, the echoed input, the output, a newline and a new prompt. Instead I get `> 1+2;\n3', that is, the current prompt, the input, and the output. Because there is no prompt indicating that maple is ready for new input, there is no way to determine that the output is complete.
To workaround this, after each complete input (terminated with : or ;) a command to print a dummy string is sent. When that string shows up in the output I know that the previous (real) output has concluded. While that works, it has limitations.
An alternative is to communicate with cmaple via a pseudo-terminal (pty). However, that introduces a lot of issues I'd rather not deal with. What I'd really like is a way to receive the prompt from the Maple process. I wonder whether the prompt is being generated but, because of buffering issues, is not available to the input process.
Is there a simple way to test, real-time, the communication to the maple process (or any linux process) by sending it "live" input from the keyboard? That is, I type a line of text, hit return, and that line, with the newline, is sent to the process. I then type a second line and that line is sent to the process. I could then observe whether Maple generates the output prompt only after it echos the entire input line.
I figured out how to do this last part. In linux, call mkfifo to create a named pipe, then direct its output to the maple process.
$ mkfifo /tmp/fifo
$ maple < /tmp/fifo
In another terminal redirect the output of the current tty to the named pipe,
$ cat < `tty` > /tmp/fifo
Subsequent lines are sent to the maple process. As described above, you'll see that the prompt following an output does not appear until the next input line is entered. To exit, type Ctrl-d, then rm the fifo,
$ rm /tmp/fifo