# (find-es "emacs" "eev-gawkdescr") proc IGNORE {args} {} procj TTT1 {txt} { PRE1 [txt2html $txt] } procj TTT-1 {txt} { TT1 [txt2html $txt] } procj << {} { return "«" } procj >> {} { return "»" } procj EEVL1 {tag txt} { AL [list eev.el $tag] $txt } procj ZSHRCL1 {tag txt} { AL [list .zshrc $tag] $txt } htmlize {Edrx's mails on eev.el} { [H2 More explanations on eev.el, adapted from mails I've sent:] [P [IT (I think that this is the best explanation of eev that I've written so far. It is a translation of a [ES {emacs eev_linux-br_message} message in portuguese] that I've sent to linux-br@unicamp.br. An [ES {emacs eev-gawkdescr} ascii version of the translation] is available\; note that the hyperlinks also work there. Read on to see how... :-)]] [P [IT (I hope you'll find the html hyperlinks useful, or at least funny. They look ugly in Netscape (sorry), but they're very pretty in lynx.)]] [P Hi. I have an Emacs Lisp package ([AL eev.el eev.el]) that is intended to let people share *nix tricks more easily and to make them addicted to source code and free software... here goes an example of how to use it: suppose that we're editing an [ES {emacs eev-gawkdescr} ascii version of this text] in an Emacs that has eev.el loaded (it was loaded with `[TT (load-library \"~/eev.el\")]', say). Then some portions of the block below can be interpreted in special ways:] [TTT1 «{# (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")}»] [P Each expression within parentheses in a \"[TT \#]\" line is in fact a block of Emacs Lisp code, that can be [ELINODE {Run a Program} executed] by placing the cursor just after the \"[TT \)]\" and then typing C-x C-e ([TT eval-last-sexp]). The first of these expressions, the one that starts with \"[TT [EEVL code-c-d-explan2 code-c-d]]\", when executed will define many Lisp functions with \"[TT gawk]\" in their names, for example \"[TT find-gawkfile]\"\; the third expression, `[TT (find-gawkfile \"debian/rules\" \"strip\")]', will open the file /usr/src/gawk-3.0.3/debian/rules and place the cursor right after the first occurrence of the string \"strip\"\; the \"[TT find-gawknode]\" expression will open the info page named \"(gawk)Numeric Functions\"\; the one with \"[TT find-gawktag]\" [ENODE {Find Tag} finds, in the gawk source files], the definition of the function \"[TT do_cos]\". That is, these expressions work as hyperlinks.] [IGNORE { # (find-node "(emacs-e20)Tags") # (find-node "(emacs-e20)Find Tag") # (find-node "(emacs-e20)Lisp Eval") # (find-node "(emacs-lisp-intro)Run a Program") }] [P The first block of text without \"[TT \#]\"s is meant to be executed by a shell\; if you set the [ENODE Mark mark] at one end of it, place the cursor at the other end, type [ENODE M-x M-x] [EEVL eev eev], and, at a shell, run \"[TT [ZSHRCL ee ee]]\", then the lines in the block will be executed by the shell almost as if they were being typed directly on the keyboard, i.e., respecting \"[TT cd]\"s, \"[TT set]\"s and \"[TT alias]\"es (the block is executed with \"[TT source]\"\; details at ...). On a Debian system this block opens the Debian source package for gawk, recompiles it and runs [ENODE {Create Tags Table} etags] on the relevant source files, to create the index that will be used by \"[TT find-gawktag]\".] [IGNORE { # (find-node "(emacs-e20)Mark") # (find-node "(emacs-e20)M-x") # (find-node "(bash)Bourne Shell Builtins" "`.'") # (find-node "(emacs-e20)Create Tags Table") }] [P The block with the \"[TTT- %]\"s has three sequences of [GDBNODE {Command Syntax} gdb commands]\; they can be sent to [GDBNODE Summary gdb] with M-x [EEVL gdb eeg], which is similar to M-x eev, or with [EEVL bounded eegdb-bounded], that sends everything between the first \"[TTT- %]\" before the cursor and the first \"[TTT- %]\" after it. As with eev, we need to give the command \"[EEVL gdb ee]\" to gdb to execute the commands sequences.] [IGNORE { # (find-node "(gdb)Command Syntax") # (find-angg "eev.el" "bounded") # (find-fline "~/.gdbinit") }] [P The command `[TT (gdb \"gdb /usr/src/gawk-3.0.3/gawk\")]' opens a [ENODE {Starting GUD} gdb session] in an Emacs [ENODE {Basic Window} window] to debug /usr/src/gawk-3.0.3/gawk.] [IGNORE { # (find-node "(emacs-e20)Starting GUD") # (find-node "(emacs-e20)Debuggers") # (find-node "(emacs-e20)Basic Window") }] [P So, the block above can be used to uncompress and install the gawk source code, to recompile it keeping the debugging symbols, to start a gdb session on it, and to trace its execution up to a certain point and then to show the values of some variables.] [P It remains to explain why certain characters, notably [TTT- ], [TTT- [<<]] and [TTT- [>>]], appear with funny colors in the htmlized versions of the ascii blocks... that's because I use a trick with [L emacs.html\#glyphs glyphs] in my [AL {.emacs glyphs512} .emacs] to make ^O (dec 15, hex 0x11, octal 017) and the chars 174 and 175 (0xae, 0256\; 0xaf, 0257) be shown as [TTT- ], [TTT- [<<]] and [TTT- [>>]] in Emacsen running in Linux in text mode\; \"[TTT- "[<<][>>]"]\" looked like a good way to show them to the general public.] [P BTW, here's how an [ES {escripts debugging_gawk} ascii version of the block above] looks like on my screen:] [IMAGE IMAGES/gawk.png (screenshot, 6kB)] [RULE] [IGNORE ----------------------------------------------------] [P [IT (The block below was part of a mail I sent to the writer of the \"Brave GNU World\" column in 2000jan23. BTW, he later wrote a very nice review of eev on [L http://www.gnu.org/brave-gnu-world/issue-13.en.html Brave GNU World #13]! :-)]] [P Hi Georg,] [P 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 ([TT eval-last-sexp] in Emacs) and other parts with M-x [TT eev] or M-x [TT eegdb-bounded]\; [TT eev], [TT eegdb-bounded] and [TT code-c-d] are defined in my package, eev.el, and [TT find-gawkfile], [TT find-gawknode] and [TT find-gawktag] become defined when one runs the code-c-d line.] [PRE1 [txt2html «{# (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")}»]] [P (...)] [HLIST2 {Links:} [J [L e/escripts.e.html#debugging_gawk http://angg.twu.net/e/escripts.e.html#debugging_gawk] - The block above] [J [L eev-manifesto.html http://angg.twu.net/eev-manifesto.html] - why eev is so important] [J [L emacs.html http://angg.twu.net/emacs.html] - docs on it, and links] ] [RULE] [IGNORE ----------------------------------------------------] [P [IT (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 [L http://angg.twu.net/]! See [L http://www.twu.net/] for his other stuff.)]] [P [IT See also: [L emacs.html], [A0L EEV/tocaspian1.txt], [A0L EEV/torms1.txt]).]] [P 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,] [PRE1 {« # (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» }] [P 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] [PRE1 {« (find-node "(gawk)String Functions" "substr(")» }] [P which corresponds to `find the info page named \"[TT String Functions]\" in the gawk info pages, and place the cursor after the first occurrence of \"[TT substr(]\". There are variations like] [PRE1 {« (find-fline "/usr/include/linux/kd.h" 11) (find-k2file "drivers/char/vt.c" "PIO_FONTX") (find-k2tag "vt_ioctl") »}] [P which mean, respectively, `open the file [TT /usr/include/linux/kd.h] and go to the line 11', `open the file [TT /usr/src/linux-2.0/drivers/char/vt.c] and search for \"[TT PIO_FONTX]\"', and `find the tag \"[TT vt_ioctl]\" in the kernel 2.0.37 sources, i.e., using the tags table [TT /usr/src/linux-2.0/TAGS]'. As any of these \"hyperlinks\" can be written preceded by a \"[TT #]\", we become able to, for example, place hyperlinks in our shell scripts...] [P As for executing blocks of text, if you mark a portion of your text, say from `[TT # (find-node \"(gawk)Top\")]' to `[TT done | tee ~/o]', and then type M-x [TT 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 `[TT 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.] [P 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\".] [P 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:] [P I have about 1M just on notes of this kind, which I call \"e-scripts\". They're temporarily at angelfire\; my page there is [L http://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...] } # [P [IT (If you can read portuguese, [ES {emacs eev_linux-br_message} # this link] will take you to the best explanation of eev that I've # written. I'll try to translate it to English and to provide a # screenshot in the next few days)].] # # [P [IT (Good news! An ascii version of the translated version is now # available [ES {emacs eev-gawkdescr} through this link]. An htmlized # version is below\; it will gain more hyperlinks very soon).]]