home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1168 / sample.rc < prev   
Encoding:
Text File  |  1990-12-28  |  2.2 KB  |  103 lines

  1. proc key_'^K' {} {
  2.     browse message {Edit key }
  3.     set key [get key]
  4.     set func key_[get keyname $key]
  5.     set file [get env HOME]/.function
  6.     if { [length [info procs $func] ] != 0 } {
  7.         set def [list proc $func {} [info body $func]]
  8.     } else {
  9.         set def [list proc $func {} { ... }]
  10.     }
  11.     print $def\n $file
  12.     browse message !vi $file
  13.     browse shell [concat vi $file]
  14.     source $file
  15. }
  16.  
  17. proc save {file args} {
  18.     if { [length $args chars] == 0 } {
  19.         print "# *** all procs ***" $file
  20.         print \n $file append
  21.         set args [info procs]
  22.     } else {
  23.         print [concat {#} $args] $file
  24.         print \n $file append
  25.     }
  26.     foreach proc $args {
  27.         set def [list proc $proc [info args $proc] [info body $proc]]
  28.         print \n$def\n $file append
  29.     }
  30. }
  31.  
  32. proc macro_'#' {} { return [get cwd] }
  33.  
  34. proc key_'s' {} { 
  35.     set f [stream open [get file .] r]
  36.     for {} { [stream gets $f line] } {} {
  37.         if {[string match Subject:* $line]} {
  38.             browse message $line
  39.             break
  40.         }
  41.     }
  42.     stream close $f
  43. }
  44.  
  45. proc key_'g' {} { 
  46.     set f [stream open [get file .] r]
  47.     for {} { [stream gets $f line] } {} {
  48.         if {[string match Newsgroups:* $line]} {
  49.             browse message [range $line 1 end]
  50.             break
  51.         }
  52.     }
  53.     stream close $f
  54. }
  55.  
  56. proc key_'i' {} {
  57.     if { [string match *line [get mode]] } { browse redraw }
  58. }
  59.  
  60. proc key_'^F' {} {
  61.     set func [get line {Edit function }]
  62.     if { [length $func chars] == 0 }
  63.         return
  64.     set file [get env HOME]/.function
  65.     if { [length [info procs $func] ] != 0 } {
  66.         set def [list proc $func {} [info body $func]]
  67.     } else {
  68.         set def [list proc $func {} { ... }]
  69.     }
  70.     print $def\n $file
  71.     browse message !vi $file
  72.     browse shell [concat vi $file]
  73.     source $file
  74. }
  75.  
  76. proc key_'S' {} { 
  77.     set f [stream open [get file .] r]
  78.     set newname [get file .]
  79.     for {} { [stream gets $f line] } {} {
  80.         if {[string match Subject:* $line]} {
  81.             set newname [get line $line\ =\ ]
  82.             break
  83.         }
  84.     }
  85.     stream close $f
  86.     browse rename [get file .] $newname
  87. }
  88.  
  89. proc key_'?' {} {
  90.     set fd [stream open [get file .] r]
  91.     for {} { [stream gets $fd line] } {} {
  92.         set line [range <$line> 0 78 chars]
  93.         set key [get key $line]
  94.         if { [string compare $key ?] != 0 } break
  95.     }
  96.     if { [string compare $key ?] == 0 } {
  97.         browse message
  98.     } else {
  99.         eval key_[get keyname $key]
  100.     }
  101.     stream close $fd
  102. }
  103.