Post by Hongyi ZhaoDoes anyone here have the experience of debugging TCL script from
within Emacs? Any hints will be highly appreciated.
Well, do this - and the somewhat similar "iterative programming of the
running app" - more or less daily.
I'm not sure what hints you are searching for, though - I works pretty
straight forward.
The basics: If you open a file with suffix .tcl then the buffer emacs
presents you to edit the file should be automatically in tcl-mode (this
is the default). If the buffer is not in tcl-mode, due to some local
configuration, just do M-x tcl-mode.
Then check what interpreter eamcs use to run your code:
C-h v tcl-application.
If the value (by default "wish") doesn't fit your needs, adjust per
configuration. This is, if ever necessary, mostly done once.
Start Tcl code from within emacs with
M-x tcl-restart-with-file
If you do this from your tcl code buffer the default file is the currently
opened file; just return the prompt.
With C-c C-s (switch-to-tcl) you get to the interpeter buffer. Within
this buffer you can evalutate any tcl commands as you would do on the
command line of a tclsh or wish process (with much mightier editing
capabilities than what the Tcl cmd prompt provides out of the box).
From this buffer you talk to the interpreter of you running application.
The return values of your interactively entered Tcl commands are shown
in the interperter buffer. You may inspect variable values or even
redefine procs of your running application.
From within the programm code buffer you can evalute a proc in the
application interpreter with C-c C-v (tcl-eval-defun) or you can
evaluate the region C-c C-x (tcl-eval-region).
For GUI development I often use this pattern: Start the application with
tcl-restart-with-file. Click thru what is needed to open the dialog you
just work on. Look at what you see. Close the dialog. Adjust the proc
that creates the dialog (say, tweak the widgets layout) and evalate that
with C-c C-v. Open the dialog again and see what changed. (Without
restarting the app and loading some example data again etc.)
rolf