Edrx's mails on eev.el

More explanations on eev.el, adapted from mails I've sent:

(This was part of a mail I sent to the writer of the "Brave GNU World" column in 2000jan23).

Hi Georg,

I have a project that I think you'll find worth a look, as the author of "Brave GNU world" or as a GNU user: it (eev.el) lets users embed chunks of code and hyperlinks in plain text files (if they use Emacs!), in such a way that one can, for example, write notes about how to unpack gawk, recompile it with debug information, start gdb on it, place a breakpoint at a certain place, and make it run until the breakpoint is reached, all that with comments interspersed that are in fact hyperlinks to the places where you got the information that led you up to that point... and instead of writing these notes in an artificial "press this, do that" style you just record what you sent to the shell and to gdb and to "replay" what you recorded you just have to mark blocks in Emacs and issue some simple commands... in this specific example, many comments in the chunk below are to be executed with C-x C-e (eval-last-sexp in Emacs) and other parts with M-x eev or M-x eegdb-bounded; eev, eegdb-bounded and code-c-d are defined in my package, eev.el, and find-gawkfile, find-gawknode and find-gawktag become defined when one runs the code-c-d line.

# (code-c-d "gawk" "/usr/src/gawk-3.0.3/" "gawk")

rm -Rv /usr/src/gawk-3.0.3/
cd /usr/src/
dpkg-source -sn -x  /big/slinks2/dists/slink/main/source/interpreters/gawk_3.0.3-1.dsc
cd /usr/src/gawk-3.0.3/
debian/rules binary	|& tee odrb
etags *.[chy]

# (find-gawkfile "odrb" "strip")
# (find-gawkfile "debian/rules" "strip")
# In the top gawk dir there's a non-stripped binary; we use it.

# (find-gawknode "Numeric Functions")
# (find-gawkfile "awktab.c" "\"cos\"")
# (find-gawktag "do_cos")

cat > /tmp/awkprog <<'---'
BEGIN { print cos(0); }
---

%*
br do_cos
set args -f /tmp/awkprog
run
p *tree
%*
p *(tree->sub.nodep.l.lptr)
%*
p *(tree->sub.nodep.l.ll)
%*

# (gdb "gdb /usr/src/gawk-3.0.3/gawk")
# (find-gawktag "lnode")


# (find-angg "eev.el" "eev")
# (find-angg "eev.el" "code-c-d")
# (find-angg "eev.el" "code-c-d-explan1")
# (find-angg "eev.el" "code-c-d-explan2")
# (find-angg "eev.el" "gdb")
# (find-angg "eev.el" "bounded")

(...) Links:


(This was part of a mail I sent to Jon "Caspian" Blank of twu.net when I was almost www-homeless (1999dec04, I think). He liked it, and after a few more mails he was hosting me at http://angg.twu.net/! See http://www.twu.net/ for his other stuff.)

See also: emacs.html, EEV/tocaspian1.txt, EEV/torms1.txt).

A small emacs-lisp package that I wrote (eev.el - URL below) defines some lisp functions that can be used as hyperlinks and some commands to execute blocks of text; for example, in the chunk of text below,

  # (find-node "(gawk)Top")
  # (find-node "(gawk)If Statement")
  # (find-node "(gawk)String Functions" "substr(")

  cd $ES/
  for i in *.e; do
    echo -n "$i: "
    awk '{if ($0=="#") {if (n==1) exit; else n+=1}
          else if (n==1) print substr($0, 3)
         }' $i
  done | tee ~/o 

if you place the cursor at the end of the last "find-node" line and type C-x C-e then Emacs evaluates the Lisp expression

  (find-node "(gawk)String Functions" "substr(") 

which corresponds to `find the info page named "String Functions" in the gawk info pages, and place the cursor after the first occurrence of "substr(". There are variations like

  (find-fline "/usr/include/linux/kd.h" 11)
  (find-k2file "drivers/char/vt.c" "PIO_FONTX")
  (find-k2tag "vt_ioctl")

which mean, respectively, `open the file /usr/include/linux/kd.h and go to the line 11', `open the file /usr/src/linux-2.0/drivers/char/vt.c and search for "PIO_FONTX"', and `find the tag "vt_ioctl" in the kernel 2.0.37 sources, i.e., using the tags table /usr/src/linux-2.0/TAGS'. As any of these "hyperlinks" can be written preceded by a "#", we become able to, for example, place hyperlinks in our shell scripts...

As for executing blocks of text, if you mark a portion of your text, say from `# (find-node "(gawk)Top")' to `done | tee ~/o', and then type M-x eev (the name of this function doesn't make much sense, but I use it so much that I had to choose something short), then you can go to another window or virtual console and run `ee', and the shell will execute the marked block almost as if you were typing it line by line, i.e, displaying each line (including blanks and comments) before executing it, and, if needed, accumulating many lines before running them together, as in the case of the "for" loop. There are some variations on eev that are meant to execute blocks of text using Tcl, Forth, gdb or perl and to run a block through LaTeX, putting some predefined lines before and after it.

Well, the moral of all this is that one can keep files of notes with lots of comments and hyperlinks, instead of having to keep hundreds of possibly incomplete scripts, and the "code" in these notes can be executed in little pieces; so we can just store the commands that accomplished something on one day, and as we use them more we can clean our preferred ones and make them more general... it's more organic than having to choose between "turn into a named script and document it", "describe everything in terms of `type this, run that'", and "Oh, I think I will remember it when I need to".

I think that people should have better ways to exchange tricks than only by scripts, source, books and verbal descriptions, and this is my contribution to it. This way obviously sprang out from my own needs, my laziness and the necessity to cope with my very weak memory... I've spent four years thinking that everybody was doing like me, until I found -- shocked and horrified -- that it was not the case... Well, too much history. Back to the main points:

I have about 1M just on notes of this kind, which I call "e-scripts". They're temporarily at angelfire; my page there is https://www.angelfire.com/or2/edrx/. It is grossly incomplete; the server I used at my university went down some weeks ago (it was a vulnerable RedHat box) and I was trying to use angelfire, but at a.f. some filenames, like .emacs, are not allowed and I can't generate all the stuff from a 300k .tar.gz and a makefile, not to count that all the htmls get banners...

(home)