home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 0 / 0980 / sample.rc < prev    next >
Encoding:
Text File  |  1990-12-28  |  1.1 KB  |  50 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. set helpfile [get env HOME]browse.help
  33.  
  34. proc key_'?' {} {
  35.     global helpfile more
  36.     set key [get keyname [get key {Help on what key (? for all)? }]]
  37.     if { [string compare '?' $key] == 0 } {
  38.         browse message !$more $helpfile
  39.         browse shell [concat $more $helpfile]
  40.     } else {
  41.         set line [exec grep ^$key $helpfile]
  42.         if { [length $line chars] > 0 } {
  43.             browse message $line
  44.         } else {
  45.             browse message {No help available on} $key
  46.         }
  47.     }
  48. }
  49.  
  50.