#!/afs/ece/usr/tcl/bin/wish -f

set Bind_Keyword [file tail [info script]]
source "[file dirname [info script]]/../aux/frame.tcl"

# Help text.
set Help "" ; append Help {Lispth -- Add keybindings for standard Lisp function/comment management.

This program teaches text widgets about Lisp functions and comments. It is
assumed that the widget will contain Lisp code.

} $TH_Bindings_Help {

Widgets of Lispth
} $TH_Frame_Help {
The heuristic for finding a function's boundaries are: A function begins with
defun (or define in Scheme), at the beginning of a line (including the open
paren), and ends with the corresponding close paren

Lispth tags all comments when teaching an application, but it does not tag the
functions. This would take too much time, it is better that the user explicitly
tag the functions if he so chooses.

It is possible to screw up the function and comment tags when editing the file.
This will not visibly affect the text, but it will screw up the Tags menu. The
'Update Function/Comment' options will fix this problem when it surfaces.
}


# Gives app all the code necessary to do our functions.
proc teach_code {} {
  global Widget
  if {[widget_bindings] == ""} {return ""}
  include_files {lisp.tcl th_defun_begin} \
	{modes.tcl th_Text_tag_regions} \
	{edit.Text.tcl th_Text_delete_range} \
	{browse.Text.tcl th_Text_select_range} \
	{paren.Text.tcl th_Text_left_exp}
  do_cmd "th_Text_tag_regions $Widget comment th_lispcomment_begin th_lispcomment_end th_lispcomment_next\n" 0
}

# For a widget, returns the appropriate bindings. (They will depend on the
# widget)
proc widget_bindings {} {
  global Bindings Class
  if {$Class != "Text"} {return ""}
  return [widget_frame_bindings $Bindings(Lisp)]
}


