home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / 3 / 3dired11.zip / DOSDIRED.CMD next >
OS/2 REXX Batch file  |  1992-08-22  |  28KB  |  906 lines

  1. ; Hi,
  2. ; This is version 1.1-Dos of Dired for MicroEMACS, enhanced and de-boned
  3. ; over the first release. I've added a couple features and cleaned
  4. ; up the code. It should work well under both Dos 4.x and Dos 5.0 now
  5. ; as well as 4DOS. 4DOS users should adjust the %dirfunc variable to dir /j
  6. ; in the initial set of "set %..."'s. Thanks very much to Richard Meitzler for 
  7. ; the 4DOS fix and for beta testing this 1.1 version. 
  8. ;
  9. ; The Unix or "ls -al" driven version exists also for anyone who would
  10. ; like to have Dired in MicroEMACS under Unix; it's version 1.1-Unix,
  11. ; and the file is unxdired.cmd.
  12. ; Of course I'm happy to hear bug reports and feedback about this code
  13. ; so don't hesitate to write if something goes wrong (or even right).
  14. ; I'm at: 
  15. ;
  16. ;        hetrick@gauge.phys.uva.nl           
  17. ;        Theoretical Physics Institute
  18. ;        University of Amsterdam, The Netherlands
  19. ;
  20. ;  Salut, 
  21. ;           Jim Hetrick
  22. ;
  23. ;=====================================================================
  24. ;
  25. ;                      =====DosDired.cmd=====  
  26. ;                          version 1.1-Dos
  27. ;
  28. ;        A Directory Facility for MicroEMACS 3.11 on the PC
  29. ;                
  30. ;        (C)opyright 1992 by James E. Hetrick 
  31. ;
  32. ;
  33. ;
  34. ;
  35. ; Dired.cmd is modeled after GNUEmacs' Dired.el to some degree.
  36. ; It lists directories, allows you to manipulate files in them, 
  37. ; and to move around your directory tree. 
  38. ;
  39. ; It relies on three other executables being in the path:
  40. ;
  41. ;    MV.EXE  --- File mover. Any one should do. If yours isn't 
  42. ;                called MV then edit the line:
  43. ;             set %mvfunc "mv " 
  44. ;          to reflect the name of your mv. Be sure to 
  45. ;         add the space at the end.
  46. ;
  47. ;   PKzip and 
  48. ;   PKunzip  --- The standards. You can also edit these parts
  49. ;                of DIRED.CMD to use LHZ or ZOO or whatever you
  50. ;                like.
  51. ;
  52. ; ******* READ THIS ***** READ THIS ****** READ THIS ********
  53. ;
  54. ; As this program has the capability to DELETE YOUR
  55. ; FILES please put some test files in a subdirectory and try it 
  56. ; out on them. After you're convinced of its integrity, put it 
  57. ; wherever your .cmd files live and fire at will. 
  58. ;
  59. ; ******* READ THIS ***** READ THIS ****** READ THIS ********
  60. ;
  61. ;
  62. ;                      ===============
  63. ;                       Documentation 
  64. ;                      ===============
  65. ;
  66. ; To Load: either -> uncomment the Dired code page below and 
  67. ;             make the changes to your emacs.rc file
  68. ;              or -> load with "execute-file dired.cmd"
  69. ;
  70. ; To Run:  hit C-x d (^XD) or M-x D-open to start dired. 
  71. ;
  72. ;       (C-x d is remapped by Dired.cmd. If you need it, 
  73. ;         remap D-open to some other key).
  74. ;
  75. ; Dired prompts you for a directory. Either type an alternative
  76. ; directory or accept (by hitting <ENTER>) the default directory
  77. ; from which MicroEMACS was called.
  78. ;
  79. ; From here you can move UP and DOWN the files with the arrow keys
  80. ; and the mouse (left button). Placing the cursor on the line of
  81. ; a file and hitting <ENTER> or clicking with the right mouse button
  82. ; loads the file into a buffer for editting replacing the Dired directory.
  83. ;
  84. ; If you type <ENTER> on a subdirectory, that subdir is loaded as
  85. ; a Dired buffer. 
  86. ;
  87. ; Dired-buffers (Dired-C:\DIR\...) are like others and stay in the 
  88. ; background while editing files or performing other tasks. If you 
  89. ; "next-buffer" (C-x x) into a Dired directory buffer, Dired starts 
  90. ; again and you have it's commands at your disposal. If you should 
  91. ; find yourself back in a Dired-buffer which is not responding to
  92. ; Dired commands such as happens when you split the screen by C-<ENTER>
  93. ; "view-file-other-window" or S-F9 "zip-view" on a . zip file, just 
  94. ; type C-x C-d to restart the Dired command processor in the window.
  95. ;
  96. ; I prefer C-x k to delete the current buffer and replace 
  97. ; with the next on the stack like GNUEmacs, so I have the 
  98. ; macro "kill-this-one" bound to C-x k, in my emacs.rc. 
  99. ; If you like it, do the same, and Dired will process it. Otherwise,
  100. ; you can comment out the !if..."kill-this-one" loop out (or leave it).
  101. ;
  102. ; ***************************************************************
  103. ;store-procedure kill-this-one
  104. ;   set %thisone $cbufname
  105. ;   set %ans @&cat &cat "Delete [" %thisone "]: "
  106. ;   !if &seq %ans ""
  107. ;      !force next-buffer
  108. ;      !force delete-buffer %thisone
  109. ;   !else
  110. ;      !force delete-buffer %ans
  111. ;   !endif
  112. ;!endm
  113. ;
  114. ;macro-to-key kill-this-one ^XK
  115. ; ****************************************************************
  116. ;
  117. ; Below is the list of Dired commands, executed singly when the cursor is
  118. ; on a file name and no files are marked (*ed), or executed on the 
  119. ; *ed files en masse:
  120. ;
  121. ;  Movement:    =   Usual: Up, Down, PgUp, PgDn, etc., and left mouse button
  122. ;
  123. ;  <ENTER>      =   Load File   (on files)
  124. ;  or right     =   Load Subdir into Dired window (on subdirs)
  125. ;  mouse button     (with mouse hit the left button first to move the
  126. ;                    point to the current line, then click the right one)
  127. ;
  128. ;  C-<ENTER>    =   Split screen, load File/Subdir in second window
  129. ;
  130. ;  C-x C-f      =   Open new file: A single name gets the currently viewed
  131. ;                   directory prepended. If the entered name contains directory 
  132. ;                   names, ie. has a "\" in it, it is opened as is.)
  133. ;
  134. ;  C-x e        =   Execute File, works on some cmd files, like CAL1.CMD
  135. ;
  136. ;  C-c          =   Exit the Dired command processor. This just leaves
  137. ;                   you in the Directory listing as an ordinary file.
  138. ;
  139. ;    When entering filenames, for copy, move, etc., a single name gets
  140. ;    the currently viewed diredctory prepended. Names which contain "\"
  141. ;    are taken as is. Names ending in ":", ie. "A:" get a "\" postfixed.
  142. ;    Below,  --- is the action on a single file, 
  143. ;            -*- is the action if files are marked.
  144. ;
  145. ;  S-F1   = Copy     --- you are prompted for a name/destination.
  146. ;             -*- prompt for dest; copy all marked files
  147. ;
  148. ;  S-F2   = Delete   --- delete file. (you're prompted)
  149. ;                   -*- or all marked files. (prompted)
  150. ;               >>>[prompting can be turned off for the brave]
  151. ;
  152. ;  S-F3   = Move     --- you are prompted for a destination.
  153. ;             -*- prompt for dest; move all marked files
  154. ;                        (exact behavior depends on your "mv" function)
  155. ;
  156. ;  S-F4   = Rename   --- rename file
  157. ;
  158. ;  S-F5   = Mark     --- Mark file with %markstr ( * ) and move to next line. 
  159. ;
  160. ;  S-F6   = Un-Mark  --- Unmarks file.
  161. ;
  162. ;  S-F7   = Revert   --- Updates Dired buffer by re-reading
  163. ;             directory from disk.
  164. ;
  165. ;  S-F8   = Make Subdir --- Make a new subdirectory 
  166. ;
  167. ;  S-F9   = PK-Zip   ---  PKzips file.
  168. ;              -*-  PKzips marked files into one zipfile.
  169. ;        file.zip  If pressed on an file ending in .ZIP, 
  170. ;                  ie. trying to zip a zipped file,
  171. ;                 invokes PKzip -v, to view contents 
  172. ;                           of file in another window.
  173. ;
  174. ;  S-F10  = PK-UnZip --- Un-zip file
  175. ;
  176. ;====================== Dired Code Page =============================
  177. ;
  178. ;; If you would like Dired to be loaded as a macro page in the function
  179. ;; key window, then uncomment the following code page loader (hacked 
  180. ;; shamelessly from from the WPAGE.CMD in the distribution). Then rename 
  181. ;; DIRED.CMD -> DPAGE.CMD and modify your EMACS.RC file to have an entry 
  182. ;; "Dired" replacing one of the pages you don't use. 
  183. ;
  184. ;; ++++++++++++++++this code page loader taken from WPAGE.CMD:+++++++
  185. ;;    DPAGE.CMD:    Dired Macro Page
  186. ;;            for MicroEMACS 3.9d and above
  187. ;;    from WPAGE.CMD:    (C)opyright 1987 by Daniel M Lawrence
  188. ;
  189. ;
  190. ;; make sure the function key window is up
  191. ;    set %rcfkeys FALSE
  192. ;    toggle-fkeys
  193. ;    write-message "Loading Dired..."
  194. ;
  195. ;; Write out the page instructions
  196. ;    save-window
  197. ;    1 next-window
  198. ;    beginning-of-file
  199. ;    set $curcol 25
  200. ;    overwrite-string " F1 Copy                 F2  Delete                 "
  201. ;    next-line
  202. ;    set $curcol 25
  203. ;    overwrite-string " F3 Move                 F4  Rename      [  C-x d  ]"
  204. ;    next-line
  205. ;    set $curcol 25
  206. ;    overwrite-string " F5 Mark                 F6  UnMark      [ invokes ]"
  207. ;    next-line
  208. ;    set $curcol 18
  209. ;    overwrite-string "DIRED]"
  210. ;    set $curcol 25
  211. ;    overwrite-string " F7 Revert Directory     F8  Make Dir    [  Dired  ]"
  212. ;    next-line
  213. ;    set $curcol 25
  214. ;    overwrite-string " F9 PK-Zip /(Zip-View)   F10 PK-Un-Zip              "
  215. ;    unmark-buffer
  216. ;    beginning-of-file
  217. ;    !force restore-window
  218. ;    update-screen
  219. ;; ++++++++++++++++++++++++++++++ 
  220.  
  221. ;========================== Dired.cmd ===========================
  222.  
  223. ; Feel free to comment out this one:
  224. write-message " -\|/-  Dired [1.1-Dos] for MicroEMACS === 1992 (c) J. E. Hetrick      >> C-x d
  225.  
  226. set %marked 0
  227. set %revert FALSE
  228. set %dot FALSE
  229. set %othwin FALSE
  230. set %dirowin FALSE
  231. set %dirfunc "dir "
  232. ;set %dirfunc "dir /j " ; 4DOS Users, uncomment this one
  233. ;set %comseq "q"        ; only needed if you use Unix style commands (see D-getcmd)
  234. set %markstr " * "     ; must be 3 chars
  235. set %mvfunc "mv "       ; name of move function PLUS a space 
  236.  
  237. ;                                           =======D-check
  238. store-procedure D-check
  239.    !if &seq &left $cbufname 6 "Dired-"
  240.        set $discmd FALSE
  241.        set %length &len $cbufname
  242.        set %dir &rig $cbufname &sub %length 6
  243.        set %Dbuffer &cat "Dired-" %dir
  244.        change-file-name " "
  245.        beginning-of-file
  246.        set %starred FALSE
  247.        set %marked 0
  248.        !while &seq %starred FALSE
  249.           !force search-forward %markstr
  250.           !if &seq $status TRUE
  251.              set %marked &add %marked 1
  252.           !else 
  253.              set %starred TRUE
  254.           !endif
  255.        !endwhile
  256.        unmark-buffer %Dbuffer
  257.        beginning-of-file
  258.        !force search-forward ".."
  259.        set %ncol &sub $curcol 2
  260.        next-line
  261.        beginning-of-line
  262.        !force %ncol forward-character
  263.        set %filename " "      
  264.        set $discmd TRUE
  265.        D-process
  266.    !endif
  267. !endm
  268.  
  269. ;                                     ==============D-open
  270. store-procedure D-open
  271.       set $discmd FALSE
  272.       !if &seq %rcfkeys TRUE
  273.          !force toggle-fkeys
  274.       !endif
  275.       pipe-command "cd"
  276.       beginning-of-file
  277.       set %cwd #command
  278.       set %dir @&cat &cat "Directory [" %cwd "]: "
  279.       !if &seq %dir "ERROR"
  280.          write-message "Aborting..."
  281.          delete-window
  282.          delete-buffer "command"
  283.          !return
  284.       !endif
  285.       delete-window
  286.       set $discmd TRUE
  287.       !if &sequal %dir ""
  288.          set %dir %cwd
  289.       !endif
  290.       D-window
  291. !endm
  292.  
  293. ;                                         =========D-window
  294. store-procedure D-window
  295.       !if &seq %revert FALSE
  296.          write-message &cat &cat "[Reading " %dir "...]
  297.       !endif
  298.       !if &seq &right %dir 1 ":"
  299.          pipe-command &cat &cat %dirfunc %dir "\"
  300.       !else
  301.          pipe-command &cat %dirfunc %dir
  302.       !endif
  303.       !if &seq %othwin FALSE
  304.          delete-other-windows
  305.       !endif
  306.       set %othwin FALSE
  307.       !if &seq %dirowin TRUE
  308.          set %dirowin FALSE
  309.      save-window
  310.      next-window
  311.          delete-window
  312.          restore-window
  313.       !endif
  314.       !force delete-buffer "stale"
  315.       set %rcfkeys FALSE
  316.       delete-mode "View"
  317.       set %Dbuffer &cat "Dired-" %dir
  318.       name-buffer %Dbuffer
  319.       change-file-name " "
  320.       beginning-of-file
  321.       set-mark
  322.       end-of-file
  323.       set %tabno $hardtab
  324.       set $hardtab 3
  325.       indent-region
  326.       detab-region
  327.       set $hardtab %tabno 
  328.       beginning-of-file
  329.       unmark-buffer %Dbuffer
  330.       !if &seq %revert TRUE
  331.          goto-line %oldline
  332.          set %revert FALSE
  333.       !else
  334.          !force search-forward ".."
  335.          !if &seq $status TRUE
  336.             set %ncol &sub $curcol 2
  337.             next-line
  338.          !else
  339.             set %ncol 3
  340.             beginning-of-file
  341.             !force 4 next-line
  342.          !endif
  343.       !endif
  344.       beginning-of-line
  345.       !force %ncol forward-character
  346.       set %filename " "      
  347.       set $discmd TRUE
  348.       D-process
  349. !endm
  350.  
  351. ;                                     ==============D-getcmd
  352. store-procedure D-getcmd
  353.  
  354. ; This is the default PC configuration: Commands are entered via the 
  355. ; S-FN keys, as this is faster. If your PC has some warp speed clock,
  356. ; your FN keys aren't working, or you prefer Unix(GNU/Tree)-like 
  357. ; commands on letter keys, ie. f, o, m, d, x, etc., comment out this 
  358. ; "PC" segment and uncomment the next section called "Unix". 
  359. ; Then change all "!if &seq %cmd..." lines in D-process to the matching 
  360. ; Unix format "!if &seq %key...". 
  361.  
  362. ; -------------------------- PC Function Key command input
  363.    !if &seq $pending FALSE
  364.       !force update-screen
  365.    !endif    
  366.    set %cmd >cmd
  367.    set %cmd &bind %cmd
  368. ; -------------------------- PC
  369.  
  370. ; -------------------------- Unix letter key command input
  371. ;   !if &seq $pending FALSE
  372. ;      !force update-screen
  373. ;   !endif
  374. ;   set %cmd " "    
  375. ;   set %key >key
  376. ;   !if &seq %key %comseq
  377. ;      write-message "Command sequence:"
  378. ;      set %cmd >cmd
  379. ;      set %cmd &bind %cmd
  380. ;      write-message %cmd
  381. ;   !endif
  382. ; -------------------------- Unix
  383.  
  384. !endm
  385.  
  386. ;                                     ==============D-process
  387. store-procedure D-process   
  388.   write-message "Dired ON"
  389.   set $discmd FALSE
  390.   set %done FALSE
  391. Porting to
  392.          another system should only be a matter of changing the
  393.          "ls" or "dir" to whatever lists directories.  !while &seq %done FALSE
  394.   D-getcmd
  395.  
  396. ; ---------------------------------------------------------------------------
  397. ; To convert to Unix-like command input switch all %cmd input !if's 
  398. ;   from:
  399. ;          !if &seq %cmd "previous-line"
  400. ;     to:
  401. ;          !if &or &or &seq %key "k" &seq %key "P" &seq %cmd "previous-line"
  402. ; by exchanging the ";" 
  403. ;----------------------------------------------------------------------------
  404.  
  405. ;======Movement======
  406.      !if &seq %cmd "previous-line"
  407. ;     !if &or &or &seq %key "k" &seq %key "P" &seq %cmd "previous-line"
  408.          !force previous-line
  409.          beginning-of-line
  410.          !force %ncol forward-character
  411.          !goto endproc
  412.      !endif
  413.  
  414.      !if &seq %cmd "previous-page"
  415. ;     !if &or &seq %key "Z" &seq %cmd "previous-page"
  416.          !force previous-page
  417.          beginning-of-line
  418.          !force %ncol forward-character
  419.          !goto endproc
  420.      !endif
  421.  
  422.      !if &seq %cmd "next-line"
  423. ;     !if &or &or &seq %key "j" &seq %key "N" &seq %cmd "next-line"
  424.          !force next-line
  425.          beginning-of-line
  426.          !force %ncol forward-character
  427.          !goto endproc
  428.      !endif
  429.  
  430.      !if &seq %cmd "next-page"
  431. ;     !if &or &seq %key "V" &seq %cmd "next-page"
  432.          !force next-page
  433.          beginning-of-line
  434.          !force %ncol forward-character
  435.          !goto endproc
  436.      !endif
  437.  
  438. ; ======Edit file====== <return>
  439.       !if &or &seq %cmd "newline" &seq %cmd "mouse-region-down"
  440. ;      !if &seq %key "f" &seq %cmd "mouse-region-down"
  441.          D-getfile
  442.          D-load-file
  443.       !endif
  444.  
  445. ; ======Edit file other window====== <C-return>
  446.       !if &seq %cmd "newline-and-indent"
  447. ;      !if &seq %key "o"
  448.          set %othwin TRUE
  449.          2 split-current-window
  450.          D-getfile
  451.          !if &seq %dirq "d"
  452.         set %dirowin TRUE
  453.      !endif
  454.          D-load-file
  455.       !endif
  456.  
  457. ; ======Copy file======= S-F1
  458.       !if &seq %cmd "execute-macro-10"
  459. ;      !if &seq %key "c"
  460.          D-getfile
  461.          !if &gre %marked 0
  462.             set %copy @"Copy marked files to: "
  463.             !if &seq %copy ".."
  464.                set %copy &cat %dir "\.."
  465.             !else
  466.                !if &seq &right %copy 1 ":"
  467.                    set %copy &cat %copy "\"
  468.                !endif
  469.                !if &equ &sind %copy "\" 0
  470.                   set %copy &cat &cat %dir "\" %copy
  471.                !endif
  472.           !endif
  473.             set %count 0
  474.             !while &gre %marked 0
  475.                beginning-of-file
  476.                search-forward %markstr
  477.                3 delete-previous-character
  478.                insert-string "   "
  479.                set %marked &sub %marked 1
  480.                D-getfile
  481.                shell-command &cat &cat &cat "copy " %filename " " %copy
  482.                set %count &add %count 1
  483.             !endwhile
  484.             write-message &cat %count " files copied"
  485.          !else
  486.             set %copy @&cat &cat "Copy  " %shortfile "  to:  "
  487.             !if &seq %copy ".."
  488.                set %copy &cat %dir "\.."
  489.             !else
  490.                !if &seq &right %copy 1 ":"
  491.                    set %copy &cat %copy "\"
  492.                !endif
  493.                !if &equ &sind %copy "\" 0
  494.                   set %copy &cat &cat %dir "\" %copy
  495.                !endif
  496.           !endif
  497.             shell-command &cat &cat &cat "copy " %filename " " %copy
  498.          !endif
  499.          D-revert
  500.          !break
  501. ;         !goto endproc
  502.       !endif
  503.  
  504. ; ======Delete file(s)== S-F2
  505.       !if &seq %cmd "execute-macro-11"
  506. ;      !if &seq %key "x"
  507.          !if &gre %marked 0
  508.             set %count 0
  509.             !while &gre %marked 0
  510.                beginning-of-file
  511.                search-forward %markstr
  512.                3 delete-previous-character
  513.                insert-string "   "
  514.                set %marked &sub %marked 1
  515.                D-getfile
  516. ; comment this set-if-loop out for no-prompt deletion of marked files
  517.                set %delq @&cat &cat "Delete  " %filename "? [y/n]"
  518.                !if &seq &low %delq "y"
  519.                   D-delete
  520.                !endif
  521.                set %count &add %count 1
  522.             !endwhile
  523.             write-message &cat %count " files deleted"
  524.          !else
  525.             D-getfile
  526. ; comment this set-if-loop out for no-prompt deletion of file
  527.             set %delq @&cat &cat "Delete  " %filename "? [y/n]"
  528.             !if &seq &low %delq "y"
  529.                D-delete
  530.             !else
  531.                write-message "No files deleted"
  532.             !endif
  533.          !endif
  534.          beginning-of-line
  535.          !force %ncol forward-character
  536.          set %delq " "
  537.          !goto endproc
  538.       !endif
  539.  
  540. ; ======Move file======= S-F3
  541.       !if &seq %cmd "execute-macro-12"
  542. ;      !if &seq %key "r"
  543.          !if &gre %marked 0
  544.             set %move @"Move marked files to: "
  545.             !if &seq %move ".."
  546.                set %move &cat %dir "\.."
  547.             !else
  548.                !if &seq &right %move 1 ":"
  549.                    set %move &cat %move "\"
  550.                !endif
  551.                !if &equ &sind %move "\" 0
  552.                   set %move &cat &cat %dir "\" %move
  553.                !endif
  554.           !endif
  555.             set %count 0
  556.             !while &gre %marked 0
  557.                beginning-of-file
  558.                search-forward %markstr
  559.                3 delete-previous-character
  560.                insert-string "   "
  561.                set %marked &sub %marked 1
  562.                D-getfile
  563.            shell-command &cat &cat &cat %mvfunc %filename " " %move
  564.                set %count &add %count 1
  565.             !endwhile
  566.             write-message &cat %count " files moved"
  567.          !else
  568.             D-getfile
  569.             set %move @&cat &cat "Move " %shortfile " to: "
  570.             !if &seq %move ".."
  571.                set %move &cat %dir "\.."
  572.             !else
  573.                !if &seq &right %move 1 ":"
  574.                    set %move &cat %move "\"
  575.                !endif
  576.                !if &equ &sind %move "\" 0
  577.                   set %move &cat &cat %dir "\" %move
  578.                !endif
  579.           !endif
  580.             shell-command &cat &cat &cat %mvfunc %filename " " %move
  581.             unmark-buffer %Dbuffer
  582.          !endif
  583.          D-revert
  584.          !break
  585.       !endif
  586.  
  587. ; ======Rename file======= S-F4
  588.       !if &seq %cmd "execute-macro-13"
  589. ;      no corresponding Unix function ("r" does both)
  590.          D-getfile
  591.          set %renm @&cat &cat "Rename  " %filename "  to:  "
  592.          shell-command &cat &cat &cat "rename " %filename " " %renm
  593.          unmark-buffer "Dbuffer"
  594.          D-revert
  595.          !break
  596.       !endif
  597.  
  598. ; =======Mark File====== S-F5
  599.       !if &seq %cmd "execute-macro-14" 
  600. ;      !if &or &seq %key "m" &seq %key "d"
  601.          beginning-of-line
  602.          set %markq &left #%Dbuffer 3
  603.          previous-line
  604.          beginning-of-line
  605.          !if &seq %markq %markstr
  606.             write-message "file already marked"
  607.          !else   
  608.             !force 3 forward-character
  609.             3 delete-previous-character
  610.             insert-string %markstr
  611.             set %marked &add %marked 1
  612.             !if ¬ &equ $curline %lastline
  613.                next-line
  614.             !endif
  615.             beginning-of-line
  616.             !force %ncol forward-character
  617.             write-message &cat %marked " marked files"
  618.             unmark-buffer %Dbuffer
  619.          !endif
  620.          !goto endproc
  621.       !endif         
  622.  
  623. ; =======Unmark file===== S-F6
  624.       !if &seq %cmd "execute-macro-15"
  625. ;      !if &seq %key "u"
  626.          beginning-of-line
  627.          set %markq &left #%Dbuffer 3
  628.          previous-line
  629.          beginning-of-line
  630.          !if &seq %markq "   "
  631.             write-message "file not marked"
  632.          !else   
  633.             3 forward-character
  634.             3 delete-previous-character
  635.             insert-string "   "
  636.             set %marked &sub %marked 1
  637.             beginning-of-line
  638.             next-line
  639.             !force %ncol forward-character
  640.             write-message &cat %marked " marked files"
  641.             unmark-buffer %Dbuffer
  642.          !endif
  643.          !goto endproc
  644.       !endif         
  645.  
  646. ; =======Revert Buffer===== S-F7
  647.       !if &seq %cmd "execute-macro-16"
  648. ;      !if &seq %key "g"
  649.          D-revert
  650.          !break
  651.       !endif
  652.  
  653. ; =======Make Sub-Directory===== S-F8 
  654.       !if &seq %cmd "execute-macro-17"
  655. ;      !if &seq %key "+"
  656.          set %mkdir @&cat &cat "sub-directory: " %dir "\"
  657.      shell-command &cat &cat &cat "mkdir " %dir "\" %mkdir
  658.          D-revert
  659.          !break
  660.       !endif
  661.  
  662. ; =======PK-ZIP===== S-F9    
  663.       !if &seq %cmd "execute-macro-18"
  664. ;      !if &seq %key "t"
  665.          D-getfile
  666.          !if &seq &right %filename 4 ".ZIP"
  667.             write-message &cat "Zip-view of " %shortfile
  668.             D-zipview
  669.             !break
  670.          !else        
  671.             !if &gre %marked 0
  672.                set %zipfile @"Name of archive file? (.zip added): "
  673.                !if &equ &sind %zipfile "\" 0
  674.                   set %zipfile &cat &cat %dir "\" %zipfile
  675.                !endif
  676.                set %zipfile &cat %zipfile ".zip"
  677.                write-message &cat &cat "Zipping marked files into " %zipfile "..."
  678.                set %count 0
  679.            !while &gre %marked 0
  680.               beginning-of-file
  681.               search-forward %markstr
  682.               D-getfile
  683.               beginning-of-line
  684.               3 forward-character
  685.               3 delete-previous-character
  686.               insert-string "   "
  687.               shell-command &cat &cat &cat &cat &cat "pkzip -b" %dir " -a " %zipfile " " %filename 
  688.               set %marked &sub %marked 1
  689.                   set %count &add %count 1
  690.            !endwhile
  691.                write-message &cat &cat %count " files zipped into " %zipfile
  692.            set %marked 0
  693.         !else
  694.            D-getfile
  695.            set %zipfile %shortfile
  696.            write-message &cat &cat &cat &cat "Zipping " %shortfile " into " %shortfile ".zip"
  697.            shell-command &cat &cat &cat &cat "pkzip -b" %dir " " %shortfile ".ZIP " %shortfile 
  698.         !endif
  699.          !endif
  700.          D-revert
  701.          !break
  702.       !endif
  703.  
  704. ; =======PK-UnZIP===== S-F10
  705.       !if &seq %cmd "execute-macro-19"
  706.          D-getfile
  707.          write-message &cat "Un-Zipping " %shortfile
  708.          shell-command &cat &cat &cat "pkunzip " %filename " " %dir
  709.          D-revert
  710.          !break          
  711.       !endif
  712.  
  713. ; =======Execute file===== C-x e
  714.       !if &seq %cmd "execute-macro"
  715. ;      !if &seq %key "a"
  716.          D-getfile
  717.          set %done TRUE
  718.          execute-file %filename
  719.          !break
  720.       !endif
  721.  
  722. ; =======Exit Dired Mode======= C-c
  723.       !if &seq %cmd "insert-space"
  724. ;      !if &seq %key "z"
  725.      write-message "Exiting Dired command processor... (C-x C-d to resume)"
  726.          set %done TRUE
  727.          !break
  728.       !endif               
  729.  
  730. ; =======Find file===== C-x C-f
  731.       !if &seq %cmd "find-file"
  732.          set %cmd " "
  733.          set %newbuf @"Find file: "
  734.          !if &equ &sind %newbuf "\" 0
  735.             set %newbuf &cat &cat %dir "\" %newbuf
  736.          !endif
  737.          !force find-file %newbuf
  738.          set %done TRUE
  739.          !break
  740.       !endif               
  741.  
  742. ; =======Pass commands=====
  743.       !if &seq %cmd "delete-buffer"
  744.          set %done TRUE
  745.          next-buffer
  746.          delete-buffer %Dbuffer
  747.       !endif
  748.  
  749.       !if &seq %cmd "[D-open]"
  750.          !force D-open
  751.       !endif      
  752.  
  753.       !if &seq %cmd "[mouse-clicks]"
  754.          !force mouse-move-down
  755.          !goto endproc
  756.       !endif      
  757.  
  758.       !if &seq %cmd "[toggle-fkeys]"
  759.          execute-procedure "toggle-fkeys"
  760.          !goto endproc
  761.       !endif      
  762.  
  763.       !if &seq %cmd "[get-help]"
  764.          execute-procedure "get-help"
  765.          !goto endproc
  766.       !endif      
  767.  
  768.       !if &seq %cmd "next-buffer"
  769.          set %done TRUE
  770.          unmark-buffer %Dbuffer
  771.          next-buffer
  772.          !goto endproc
  773.       !endif      
  774.  
  775.       !if &seq %cmd "[kill-this-one]"
  776.          set %done TRUE
  777.          set %cmd " "
  778.          execute-procedure kill-this-one
  779.          !goto endproc
  780.       !endif      
  781.  
  782.       !force execute-named-command %cmd
  783.  
  784.       *endproc
  785.    !endwhile
  786. !endm
  787.  
  788. store-procedure D-getfile
  789.    end-of-line
  790.    !if &les $curcol %ncol
  791.       write-message "Not positioned on file or directory"
  792.       !goto endget
  793.    !endif
  794.    beginning-of-line
  795.    17 forward-character
  796.    set %dirq &low &left #%Dbuffer 1
  797.    previous-line
  798.    beginning-of-line
  799.    3 forward-character
  800.    set %ffront &trim &left #%Dbuffer 8
  801.    previous-line
  802.    beginning-of-line
  803.    12 forward-character
  804.    set %fext &left #%Dbuffer 3
  805.    !if ¬ &seq %dirq "d"
  806.       set %filename &trim &cat &cat %ffront "." %fext
  807.    !endif
  808.    !if &seq %ffront "."
  809.       write-message "Tried to open ~".~" (Use S-F7 to revert buffer)"
  810.       previous-line
  811.       !force %ncol forward-character
  812.       set %dot TRUE
  813.       !goto endget
  814.    !endif
  815.    !if &seq %dirq "d"
  816.       !if &seq %ffront ".."
  817.          set %testdir &upper %dir
  818.          set %orgdir %testdir
  819.          set %dirlen &len %testdir
  820.          set %orglen %dirlen
  821.          set %slash &sind %testdir "\"
  822.          !while ¬ &equ %slash 0
  823.             set %testdir &right %testdir &sub %dirlen %slash
  824.             set %dirlen &len %testdir
  825.             set %slash &sind %testdir "\"
  826.          !endwhile
  827.          set %newdir &left %orgdir &sub %orglen &add 1 &len %testdir
  828.       !else
  829.          set %newdir &cat &cat %dir "\" &upper %ffront
  830.       !endif
  831.    !else
  832.       set %shortfile %filename
  833.       set %filename &cat &cat %dir "\" %filename
  834.       set %dirq " "
  835.    !endif
  836.    previous-line
  837.    !force %ncol forward-character
  838.    *endget
  839. !endm 
  840.  
  841. ;                                     ==============D-load-file
  842. store-procedure D-load-file
  843. !if &seq %dot FALSE
  844.    !if &seq %dirq "d"
  845.       !force delete-buffer &cat "Dired-" %newdir
  846.       set %dirq " "
  847.       set %dir %newdir
  848.       !if &seq %revert FALSE
  849.          write-message &cat &cat "[Reading " %dir "...]"
  850.       !endif
  851.       set %done TRUE
  852.       D-window
  853.    !else
  854.       write-message &cat &cat "[Reading " %filename "...]"
  855.       !if &seq %othwin FALSE
  856.          delete-other-windows
  857.       !else
  858.          set %othwin FALSE
  859.       !endif
  860.       !force  find-file %filename
  861.       set %done TRUE
  862.    !endif
  863. !endif
  864.    set %dot FALSE
  865.    *loadend
  866. !endm
  867.  
  868. ;                                     ==============D-delete
  869. store-procedure D-delete
  870.    write-message &cat &cat "Deleting  " %filename "..."
  871.    shell-command &cat &cat "del " %filename
  872.    beginning-of-line
  873.    1 kill-to-end-of-line
  874.    set %lastline &sub %lastline 1
  875.    update-screen
  876.    unmark-buffer %Dbuffer
  877. !endm
  878.  
  879. ;                                     ==============D-zipview
  880. store-procedure D-zipview 
  881.    set %cmd " "
  882.    !force pipe-command &cat "pkzip -v " %filename
  883.    set %done TRUE
  884.    name-buffer %shortfile
  885.    change-file-name "zip-view"
  886.    beginning-of-file
  887.    update-screen
  888. !endm
  889.  
  890. store-procedure D-revert
  891.   set %revert TRUE
  892.   set %oldline $curline
  893.   name-buffer "stale"
  894.   unmark-buffer "stale"
  895.   D-window
  896. !endm
  897.  
  898. set $discmd FALSE
  899. macro-to-key D-open ^XD
  900. macro-to-key D-check ^X^D
  901. set $bufhook D-check
  902. set $discmd TRUE
  903.  
  904.