#!/afs/ece/usr/tcl/bin/wish -f
# The next line is executed by most shells, but not Tcl \
wish $0 $*

#
# Mail sending program, Can be used as -whatnowproc 
#

set cwd [pwd]
if {([string match /* [info script]])} {
	set bethmail_dir [file dirname [info script]]
} else {set bethmail_dir [file dirname $cwd/[info script]]}
cd $bethmail_dir

set folder "drafts"
set w .syme1.t
set f .syme1.t_fm
source ../aux/mailth.tcl

set list [exec ls $mail_dir/$folder]
set this [lindex $list end]
set argv "-a -i -c {th_add_module paragrath} $mail_dir/$folder/$this"
set argc [llength $argv]
source elsbeth

wm title .syme1 "Mail: Send"
wm iconname .syme1 "MS"
.syme1.t configure -width 70

$f.fnl invoke

pack propagate $f 1
button $f.send -text Send -command "exec touch $TH(File,$w) ; th_save_file $w ; exec send $TH(File,$w)"
pack $f.send -side left -expand yes -fill x
$f.quit configure -command exit
pack propagate $f 0

bind . <Destroy> {if {[file exists $TH(File,$w)]} {exec rm $TH(File,$w)}}


if {[set dash_index [$w search -forward -exact -- "---" 1.0 end]] != ""} {
  $w tag add protect $dash_index "$dash_index lineend"
}
add_section_tags $w
