Warning: this is a htmlized version!
The original is across this link. |
####### # # E-scripts on e-scripts. # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at <http://angg.twu.net/a/e/escripts.e> # or at <http://angg.twu.net/e/escripts.e.html>. # See also <http://angg.twu.net/emacs.html>, # <http://angg.twu.net/a/.emacs[.html]>, # <http://angg.twu.net/a/.zshrc[.html]>, # <http://angg.twu.net/escripts.html>, # and <http://angg.twu.net/>. # ####### ###### # # a first e-script demo: debugging gawk (+ explanations) # 00jan23 # ###### # «debugging_gawk» 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 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") ####### # # locating escript headers in emacs (old) # ####### ; (fundamental-mode) ; (emacs-lisp-mode) ; (find-elnode "Top") ; (find-elnode "Searching and Matching") ; (find-elnode "Syntax of Regexps") ; (find-enode "Top") ; (find-enode "Top" "Regexp Search") ; (find-enode "Command Index" "isearch-forward-regexp") ; (find-etag "isearch-forward-regexp") (setq eregexp (let ((li1 "####*") (li2 "#") (li3 "# \\(.*\\)") (li4 "#") (li5 "####*")) (format "\n\n%s\n%s\n%s\n%s\n%s\n\n" li1 li2 li3 li4 li5))) (let ((regexp-search-ring (list eregexp))) (isearch-forward-regexp)) ; Uso: C-M-s tclsh <<'---' set re "\n\n####*\n#\n# \\(.*\\)\n#\n####*\n\n" set re "\n\n####*\n#\n# (.*)\n#\n####*\n\n" set s "a\n\n#####\n#\n# foo\n#\n######\n\nb" set fid [open "~/ZHTML/escripts/icon.e"] set s [read $fid] puts [regexp $re $s] puts [regexp $re foo] --- ###### # # Converting escripts to html (perl version; old) # ###### # «escripts_to_html» # (find-pl5file "HTML/") # (find-pl5file "HTML/Entities.pm") # (find-fline "~/bin/e2html") cat $ES/escripts.e \ | 850toiso -s \ | perl -e 'use HTML::Entities; print "<head></head><body><pre>"; while ($_ = <>) { if (m/^((#+ |;+ |\\ |\\; )\0253(.*)\0273\n$/) { print "<a name=\"$3\">", encode_entities($1), "</a>\n"; } else { print encode_entities($_); } } print "</pre></body>\n";' \ > /tmp/o.html pdsc /debian/dists/slink/main/source/text/tcs_1-4.dsc $a = "Våre norske tegn bør æres"; decode_entities($a); encode_entities($a, "\200-\377"); ##### # # Checking if all headers are OK # 99sep?? # ##### # (find-enode "Fill Commands") # (find-enode "Fill Commands" "adaptive-fill-mode") # (find-enode "Text Mode" "indented-text-mode") set escripts {anggsmil.e bis.e cartas.e crim.e debian.e debian0.e debiandev.e dos.e emacs.e escripts.e ethernet.e fl.e forth.e games.e general.e gimp.e greenmatrix.e hardware.e html.e icon.e icq.e k22.e kernel.e mail.e maple.e mini.e music.e net.e netscape.e nonfree.e page.e perl.e perl1.e ppp.e print.e psx.e raven10.e raven10b.e redhat.e rest.e scheme.e secret.e slink.e sql.e tcl.e tese.e tex.e todo.e transp.e vivamusica.e yard.e zsh.e} proc getheaderlines {fname} { set lines [split [exec cat /home/root/ZHTML/escripts/$fname] "\n"] puts "$fname [llength $lines]" set headerlines {} foreach line $lines { lappend headerlines $line if {$line==""} {break} } return $headerlines } proc writefile {fname str} { set channel [open $fname w]; puts -nonewline $channel $str; close $channel } foreach fname $escripts { writefile /tmp/$fname [join [getheaderlines $fname] "\n"] } eet cd /tmp; for i in *.e; do echo "\n\n$i kernel.e"; diff $i kernel.e; done rm /tmp/*.e ###### # # Checking the headers with an expect script # 99oct14 # ###### # «eheaders» # (find-fline "~/EXPECT/eheaders") cd $ES eheaders *.e ###### # # Adjusting the headers # 99nov03 # ###### # «adjusting_eheaders» # (find-fline "~/EXPECT/eheaders") expect -c ' proc readfile {fname} { set channel [open $fname r]; set bigstr [read $channel]; close $channel return $bigstr } set s [readfile $env(ES)/emacs.e] set v "#\n" set nv "#\[^\n\]+\n" set com "#\[^\n\]*\n" set bigre "^$nv${v}(($nv)+)${v}(($com)+)(.*)\$" if {[regexp $bigre $s -> descr {} hrest {} rest]} { puts "<<$descr>>\n<<$hrest>>\n<<$rest>>" } ' # «fix-eheaders» # (find-fline "~/TCL/fix-eheaders") rm -Rv /tmp/e mkdir /tmp/e cd $ES ~/TCL/fix-eheaders *.e # eheaders /tmp/e/*.e cp -v /tmp/e/*.e $ES/ # (find-fline "~/TCL/fix-eheaders" "splite") # (find-fline "~/TCL/fix-eheaders" "Bad efile") ##### # # find-es as a cgi # 2000jan03 # #####