Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
Tcl: set tcl_prefix "" # From this point on all the lines that start with the "null prefix" # (i.e., all lines!) will be treated as Tcl commands... # This is my "gdbk" demo, converted to eeg3 format. # Edrx, 2001may15. # (find-angg ".zshrc" "demo") # (find-angg "README") # (find-angg "EXPECT/eeg3") # (find-angg "EEG/gdbk.eeg") # (find-angg "EEG/gdbk.eeg3") # (find-es "eeg" "escripts_demo_1") in_screen ##### # # A block with ways to test this eegscript (ignore this block) # ##### proc comment {args} {} comment { #* cp ~/EEG/gdbk.eeg3 $EEG eeg3 -c 'showactions; exit' echo > ~/o less -S $EEG ~/o #* cp ~/EEG/gdbk.eeg3 $EEG # eeg3 screen emacs -nw $ES/anatocc.e; set +v; return eeg3 -c 'showactions; exit' screen emacs -nw $ES/anatocc.e; set +v; return #* cp ~/EEG/gdbk.eeg3 $EEG eeg3 screen /usr/src/emacs-21.0.93/src/emacs -nw $ES/anatocc.e; set +v;return #* # Run the demo in the standard way # (find-angg ".zshrc" "demo") demo gdbk; set +v;return #* # Test the ability of running quickly over some parts EEGQUICK="e1 sh e2" demo gdbk; set +v;return #* } # (find-node "(expect)debug") # (find-node "(expect)interpreter") proc cls {} { send_user "\033\[2J" } proc S {} { stty sane } # setwait 0 # append_action "setwait 0; stty sane; debug 1" ##### # # The eegscript itself # ##### proc isquick {tag} { expr "[lsearch [getenv EEGQUICK] $tag]!=-1" } proc setwait-eegquick {tag} { setwait [expr "![isquick $tag]"] } setwait-eegquick e1 # setwait 1 # setwait 0 msg \ {Next key: C-s (isearch-forward) Will start an interactive search. Keyboard input will appear at the last line of the screen (the "minibuffer") but the cursor will be pointing to the matching position.} ks C-s d l o p e n ret msg \ {Next key: M-e (end-of-line-then-eval-last-sexp) Will follow the "to" hyperlink.} k M-e msg {Arrows move.} ks down down down down down msg \ {M-0 ... M-9 form a number that some commands use as a repetition count. The next command is M-5 down.} ks M-5 down msg \ {C-l (recenter) adjusts the display to place the cursor in the middle.} k C-l msg \ {F3 (ee-default-strbounded, will work as eev-bounded now) Will save the block between the delimiters to a temporary script file (~/bin/ee.sh).} k f3 setwait 1 msg \ {We will now switch to a shell with C-a c. This C-a c is not an Emacs command; we are now running Emacs under a program called "screen", that makes a single terminal act as many, and screen will interpret C-a c as its command to create a new shell "window" and switch to it; I hope you have tried the demo of "screen" before this one, because if you haven't you may become somewhat puzzled.} k C-a c # We are now in a shell! l {exec zsh} setwait-eegquick sh msg \ {Now the command "ee" will execute the saved block. It is not exactly a command, it is a shell alias:} l {alias ee} l {echo $EE} l {cat $EE} msg {Let's run "ee" now.} l ee msg {It wrote two C programs, "x.c"...} l {cat x.c} msg {and "so.c"...} l {cat so.c} msg \ {and compiled "so.c" into a shared library and "x.c" into an executable file, "x":} l {laf} msg \ {then "x" was ran, and it called a function that was defined in so.c. Let's run "x" again and then clear the screen and run "ee" again, and you'll see how "ee" did all that in a single blow.} l {./x} k C-l l {ee} msg \ {As we compiled everything with "-g" it will be possible to run gdb (a debugger) on "x". Emacs provides a fantastic debugging environment, so we will switch back to Emacs... We'll use the key sequence C-a 0 for that; screen interprets it as "go to the window 0".} setwait 1 k C-a 0 msg {Go to the "gdbk-gdb" hyperlink (using "C-s (gdbk-").} k C-s ( g d b k - ret msg \ {Now execute the hyperlink with M-e; this will 1) save everything between the delimiters another temporary file, ~/bin/ee.generic (this step would have been skipped if the first argument to `gdbk-gdb' were not `t'), and 2) invoke gdb, inside Emacs, on /tmp/x, adding support for some convenient keys.} k M-e msg \ {GDB also supports an "ee" command; it will make it execute the commands stored in ~/bin/ee.generic, that were "br main" and "run".} l {ee} msg {Now single-step several times (10, to be precise) with M-s and M-n.} ks M-n M-n M-n M-s M-n ks M-n M-n M-n M-n M-n setwait-eegquick e2 msg {Now kill the gdb window, with M-k enter.} ks M-k enter msg {Kill the buffer visiting x.c, with M-k enter.} ks M-k enter msg \ {Leave Emacs with C-x C-c (save-buffers-kill-emacs), and after that leave the shell with C-d; screen will notice that all programs it was running have finished, and will finish too.} k C-x C-c setwait 1 k C-d