home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume5 / ue3.9-macros / enhance.cmd next >
OS/2 REXX Batch file  |  1989-02-03  |  4KB  |  168 lines

  1. ; enhance.cmd
  2. ;
  3. ; MicroEMACS 3.9 macros
  4. ;
  5. ; I.  New bindings
  6. ;    A.  ESC-ESC -> execute command line
  7. ;    B.  ESC-^X  -> execute current buffer
  8. ;    C.  ESC-TAB -> toggle OVERstrike mode
  9. ;    D.  ESC-#   -> filter region through a program
  10. ; II.  Enhancements to existing bindings
  11. ;    B.  ^X! allows response of "!" to repeat previous command
  12. ;    C.  ^X^F, ^X^V, ^X^R, ^X^I, ^X^W, ^X^N expand ~/file properly
  13. ;    D.  ^X^F, ^X^V, ^X^R, ^X^I check if the file exists only in
  14. ;        compressed form (ending with ".Z"), and if so, uncompress it
  15. ;
  16. ; David MacKenzie
  17. ; Latest revision: 09/08/88
  18.  
  19.  
  20. ; Set up ESC-ESC to execute a macro language command from keyboard.
  21. bind-to-key execute-command-line M-^[
  22.  
  23. ; Set up ESC-Ctrl-X to execute the current buffer.
  24. 1 store-macro
  25.     execute-buffer $cbufname
  26. !endm
  27. bind-to-key execute-macro-1 M-^x
  28.  
  29. ; Set up M-TAB to toggle insert/overstrike.
  30. 2 store-macro
  31.     set $cmode &bxor $cmode 32
  32. !endm
  33. bind-to-key execute-macro-2 M-^I
  34.  
  35. ; Add !! (repeat previous command) capability to shell-command.
  36. ; Activated by a response of "!<Return>".
  37. set %prev-cmd "!"
  38. 3 store-macro
  39.     set %shell-cmd @"!"
  40.     !if &sequal %shell-cmd "ERROR"  ; Ctrl-G hit.
  41.         !return
  42.     !endif
  43.     !if &sequal %shell-cmd "!"
  44.         !if &sequal %prev-cmd "!"
  45.             write-message "[No previous command]"
  46.             !return
  47.         !endif
  48.         ; Echo the command we're repeating for reference, a la csh.
  49.         write-message &cat "!"  &cat %prev-cmd "~r~n"; CRLF
  50.         set %shell-cmd %prev-cmd
  51.     !else
  52.         set %prev-cmd %shell-cmd
  53.     !endif
  54.     shell-command %shell-cmd
  55.     write-message "[End]"
  56.     set %rckey >key
  57. !endm
  58. bind-to-key execute-macro-3 ^X!
  59.  
  60. ; If %fname starts with "~/", substitute the value of HOME from environ.
  61. store-procedure tildesub
  62.     ; ~ is MicroEMACS's escape character so we need to escape it.
  63.     !if &sequal &left %fname 2 "~~/"
  64.         set %fname &cat  &env "HOME"  &right %fname &sub &length %fname 1
  65.     !endif
  66. !endm
  67.  
  68. ; If %fname exists only as a compressed file, uncompress it first.
  69. store-procedure zcheck
  70.     !if &and ¬ &exi %fname  &exi &cat %fname ".Z"
  71.         shell-command &cat "uncompress -v " %fname
  72.     !endif
  73. !endm
  74.  
  75. ; Add tilde substitution on file finding, viewing, etc.
  76. 4 store-macro
  77.     set %fname @"Find file: "
  78.     !if &sequal %fname "ERROR"  ; Ctrl-G hit.
  79.         !return
  80.     !endif
  81.     run tildesub
  82.     run zcheck
  83.     find-file %fname
  84. !endm
  85. bind-to-key execute-macro-4 ^X^F
  86.  
  87. 5 store-macro
  88.     set %fname @"View file: "
  89.     !if &sequal %fname "ERROR"
  90.         !return
  91.     !endif
  92.     run tildesub
  93.     run zcheck
  94.     view-file %fname
  95. !endm
  96. bind-to-key execute-macro-5 ^X^V
  97.  
  98. 6 store-macro
  99.     set %fname @"Read file: "
  100.     !if &sequal %fname "ERROR"
  101.         !return
  102.     !endif
  103.     run tildesub
  104.     run zcheck
  105.     read-file %fname
  106. !endm
  107. bind-to-key execute-macro-6 ^X^R
  108.  
  109. 7 store-macro
  110.     set %fname @"Insert file: "
  111.     !if &sequal %fname "ERROR"
  112.         !return
  113.     !endif
  114.     run tildesub
  115.     run zcheck
  116.     insert-file %fname
  117. !endm
  118. bind-to-key execute-macro-7 ^X^I
  119.  
  120. 8 store-macro
  121.     set %fname @"Write file: "
  122.     !if &sequal %fname "ERROR"
  123.         !return
  124.     !endif
  125.     run tildesub
  126.     write-file %fname
  127. !endm
  128. bind-to-key execute-macro-8 ^X^W
  129.  
  130. 9 store-macro
  131.     set %fname @"Name: "
  132.     !if &sequal %fname "ERROR"
  133.         !return
  134.     !endif
  135.     run tildesub
  136.     change-file-name %fname
  137. !endm
  138. bind-to-key execute-macro-9 ^XN
  139.  
  140. ; Filter the region through an external command.
  141. 10 store-macro
  142.     set %filt-cmd @"#"
  143.     !if &or  %sequal %filt-cmd "ERROR"  &sequal %filt-cmd ""
  144.         !return
  145.     !endif
  146.     write-message "[Filtering region]"
  147.     kill-region
  148.     2 split-current-window
  149.     select-buffer "[temp]"
  150.     yank
  151.     end-of-file
  152.     delete-previous-character ; Remove unwanted extra newline.
  153.     unmark-buffer
  154.  
  155.     filter-buffer %filt-cmd
  156.  
  157.     beginning-of-file
  158.     set-mark
  159.     end-of-file
  160.     kill-region
  161.     unmark-buffer
  162.     delete-window
  163.     yank
  164.     delete-buffer "[temp]"
  165.     write-message "[Region filtered]"
  166. !endm
  167. bind-to-key execute-macro-10 M-#
  168.