File: func_edit.tcl

package info (click to toggle)
staden 2.0.0%2Bb11-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,584 kB
  • sloc: ansic: 240,605; tcl: 65,360; cpp: 12,854; makefile: 11,203; sh: 3,023; fortran: 2,033; perl: 63; awk: 46
file content (25 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Allows editing of Tcl functions from within the console
proc func_edit {func} {
    if {[catch {info arg $func} err]} {
	tk_messageBox -message $err
	return
    }

    set t "[tmpnam].tcl"
    set fd [open $t w]
    puts $fd "proc $func [list [info arg $func]] {[info body $func]}"
    close $fd

    #exec xterm -e emacs -nw $t
    exec xemacs $t

    set fd [open $t r]
    set code [read $fd]
    close $fd
    file delete $t

    if {[catch {uplevel #0 $code} err]} {
	tk_messageBox -message $err
	return
    }
}