[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[eev] Sending lines one at a time to processes running in Emacs buffers
From: |
Eduardo Ochs |
Subject: |
[eev] Sending lines one at a time to processes running in Emacs buffers |
Date: |
Sun, 11 Dec 2005 23:35:40 -0200 |
Hi list,
Sorry for my silence in these last months - as my finances were
reaching the triple-red mark I started to invest all my time and
energy into making myself visible in the real world and getting a
real-world job... and well, it worked, but the development of eev (and
of blogme, and of dednat4) suffered. Anyway: in my real-world job I
have to use a super-crippled environment - a W$ box into which I
cannot even install Cygwin (because of some evil security scripts),
and use that to connect via telnet to a machine running AIX... I had
to do a series of enhancements to eev to deal with that environment;
in this posting I will describe one of them.
Sending lines one at a time to processes running in Emacs buffers
=================================================================
What we already had: F9
-----------------------
Typing <f9> with eev-mode on runs `eechannel-do-this-line' (the name
of the command is horrible, sorry), which sends the current line to an
external process through the current "communication channel"; as a
special case, if the line starts with a red star it is evaluated
immediately as lisp code, instead of being sent. This evaluation
mechanism works differently from the one used for hyperlinks: when we
execute a hyperlink sexp with `M-e' we evaluate the last sexp in the
line and we ignore the rest, while evaluation of red-star lines starts
from the left: in the example below, where I'm writing the red stars
as "^O"s,
#^O
^O (shell) ;; (eestore-bounded)
echo $[1+2]
echo foo
#^O
typing <f9> on the "^O (shell) ;; (eestore-bounded)" line would run
"(shell)", while typing `M-e' would run "(eestore-bounded)".
Internally, <f9> uses `ee-eval-string' on the text of the line minus
the initial red star; `ee-eval-string' is defined as
(defun ee-eval-string (str)
(eval (read (concat "(progn\n" str "\n)"))))
and so "^O (shell) ;; (eestore-bounded)" is converted to
(progn (shell) ;; (eestore-bounded)
)
and then evaluated; so, red star lines can contain any number of
sexps, even zero, and can have a comment part.
New feature: M-P
----------------
I used to have `M-P' (meta-shift-p - don't forget the shift!) bound to
a command that would yank lines from the last kill one at a time,
issuing a RET after each one; that was nice for pasting text into IRC
buffers, but not for much more, so that command was left in my .emacs
and I never made any fuss about it. But with the addition of special
treatment for red star lines it became incredibly useful, especially
when used together with its new buddies `eestore' and
`eestore-bounded'... `eestore' is essentially a `M-w'
(`kill-ring-save') in disguise, and `eestore-bounded' is just a
bounded version of it. So, running the "... (eestore-bounded)" line in
#^O
^O (shell) ;; (eestore-bounded)
echo $[1+2]
echo foo
#^O
with `M-e' saves the block between the delimiters in the kill ring,
and flashes it green for a short while; then typing `M-P' processes
the first line, which opens a shell interaction buffer; typing `M-P'
again sends the "echo $[1+2]" line to the shell, typing `M-P' another
time sends the "echo foo", and further `M-P's give an error - "No more
lines" - because then the top entry in the kill ring will be empty.
The docstring for `eestore' includes a runnable example - actually
exactly the one above, but with red stars and with the right
indentation. Try:
(find-efunctiondescr 'eestore)
A problem: when comint sees a password prompt it enters a special mode
in which M-P doesn't work, so passwords need to be typed by hand. It
shouldn't be hard to disable the checking for password prompts, but I
haven't tried that yet.
For those wanting to inspect the code without downloading the new
version of eev-current, here is a direct link:
<http://angg.twu.net/eev-current/eev.el.html#ee-yank-one-line>
Cheers,
Edrx
--
http://www.fastmail.fm - Send your email first class
- [eev] Sending lines one at a time to processes running in Emacs buffers,
Eduardo Ochs <=