★ semi-automated interactive stream editing: piping through expect and emacs ★
Here, the eipe2
script wraps around
emacsclient to enable myself to intercept the
traffic of a bash pipeline and edit it mid-command. It’s modelled after vipe
.
But that is only half the trick. I then do the
same for tcl/expect
. On its own, expect
can’t
edit the stream, but by placing an eipe2
within the expect script I can complete the
pipeline, automating emacs with expect.
But that is not the most awesome part. Although expect could fully automate emacs, I hand over control to the user before exiting expect, allowing the user to make some final adjustments to the data before continuing the pipeline.
The final command and an explanation
This commands pipes the html through expect, which spawns emacs and runs a few automated key presses to prepare the user for editing.
Command is then given to the user to do some editing.
When the buffer is killed, the emacs frame is also killed and the contents of the killed buffer is piped into vim.
Sadly I can’t explain it all here as there are so many components at work, but the result makes semi-automated stream editing using an interactive TUI possible and very easy to use.
|
|
Demonstration
The generated expect script
|
|
How it works - script snippets
I’m just going to copy out some of the important parts of the following scripts.
Explaining it all will take too long.
eipe2
|
|
sp
|
|
my-frame.el
|
|
x
|
|
Generated expect code
|
|
TTY must be unset so the spawned scripts can
determine the TTY from the /dev/tty
command.
nsfa
|
|
This part is where the magic happens.
|
|
tm-tty
|
|
If this article appears incomplete, it may be intentional. Try prompting for a continuation.