#!/bin/sh # -*- tcl -*- # Tcl sees the next 5 lines as an assignment to variable `kludge'. # For sh, the two shifts cancel the effect of the set, and then we # run wish on this script. set kludge { $* shift shift exec wish4.0 -file $0 $* } wm withdraw . proc send-listener {string} { send emacs-listener [list send-emacs $string] } set find_proc find-file proc find-file {fname} { global find_proc send-listener "\(prog1 \($find_proc \"$fname\"\) \(deiconify-frame\)\)" } proc car {list} { return [lindex $list 0] } proc cdr {list} { return [lrange $list 1 [llength $list]] } if {[lsearch [winfo interp] emacs-listener] == "-1"} { puts stderr "emacs-listener not found" exit 1 } if {[car $argv] == "-i"} { while {![eof stdin]} { puts -nonewline stdout "> " flush stdout set line [gets stdin] send-listener $line } } elseif {[car $argv] == "-l"} { send-listener [cdr $argv] } else { if {[car $argv] == "-v"} { set find_proc view-file set argv [cdr $argv] } while {$argv != ""} { find-file [pwd]/[car $argv] set argv [cdr $argv] } } exit