home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / 3 / 3dired11.zip / UNXDIRED.CMD < prev   
OS/2 REXX Batch file  |  1992-08-22  |  27KB  |  872 lines

  1. ; This is version 1.1-Unix of Dired for MicroEMACS, enhanced and de-boned
  2. ; over the first DOS release. I've added a couple features and cleaned
  3. ; up the code.  Thanks very much to Richard Meitzler for beta testing this 
  4. ; 1.1 version. It's been tested on a Sparc station and an IBM RISC 6000.
  5. ;
  6. ; Version 1.1-Dos also exists for dired.cmd; the file is called dosdired.cmd
  7. ;
  8. ; Of course I'm happy to hear bug reports and feedback about this code
  9. ; so don't hesitate to write if something goes wrong (or even right).
  10. ; I'm at: 
  11. ;
  12. ;        hetrick@gauge.phys.uva.nl          
  13. ;        Theoretical Physics Institute
  14. ;        University of Amsterdam, The Netherlands
  15. ;
  16. ;  Salut, 
  17. ;           Jim Hetrick
  18. ;
  19. ;=====================================================================
  20. ;
  21. ;                      =====UnxDired.cmd=====  
  22. ;                          version 1.1-Unix
  23. ;
  24. ;        A Directory Facility for MicroEMACS 3.11 under Unix
  25. ;                
  26. ;        (C)opyright 1992 by James E. Hetrick 
  27. ;
  28. ;   Dired.cmd is modeled after GNUEmacs' Dired.el to some degree.
  29. ;   It lists directories, allows you to manipulate files in them, 
  30. ;   and to move around your directory tree. 
  31. ;
  32. ; ******* READ THIS ***** READ THIS ****** READ THIS ********
  33. ;
  34. ; As this program has the capability to DELETE YOUR
  35. ; FILES please put some test files in a subdirectory and try it 
  36. ; out on them. After you're convinced of its integrity, put it 
  37. ; wherever your .cmd files live and fire at will. 
  38. ;
  39. ; ******* READ THIS ***** READ THIS ****** READ THIS ********
  40. ;
  41. ;
  42. ;
  43. ;                      ===============
  44. ;                       Documentation 
  45. ;                      ===============
  46. ;
  47. ; To Load: either -> uncomment the Dired code page below and 
  48. ;             make the changes to your .emacsrc file
  49. ;              or -> load with "execute-file unxdired.cmd"
  50. ;
  51. ; To Run:  hit C-x d (^XD) or M-x D-open to start dired. 
  52. ;
  53. ;       (C-x d is remapped by Dired.cmd. If you need it, 
  54. ;         remap D-open to some other key).
  55. ;
  56. ; Dired prompts you for a directory. Either type an alternative
  57. ; directory or accept (by hitting <ENTER>) the default directory
  58. ; from which MicroEMACS was called.
  59. ;
  60. ; From here you can move UP and DOWN the files with the arrow keys.
  61. ; Tapping "f" loads the file into a buffer for editting replacing the 
  62. ; Dired directory.
  63. ;
  64. ; If you hit "f" on a subdirectory, that subdir is loaded as
  65. ; a Dired buffer. 
  66. ;
  67. ; In a Dired buffer there is a new META key, so to speak, "q" by
  68. ; default. Usually one tells Dired what to do by hitting letter keys
  69. ; "f", "o", "m", etc., as in it's GNU inspiration. Should you need 
  70. ; to do something which is bound to a control sequence, like C-x k 
  71. ; (delete-buffer) or C-x x (next-buffer), you first type "q", Dired will 
  72. ; then prompt you with "Command sequence:". Here you enter a normal
  73. ; control sequence, and Dired will process it as best it can. Using 
  74. ; "q" as the Dired-META key, avoids the difficulties that seem
  75. ; arise in using the function keys across a variety of different machines. 
  76. ;
  77. ; Dired-buffers (Dired-C:\DIR\...) are like others and stay in the 
  78. ; background while editing files or performing other tasks. If you 
  79. ; "next-buffer" q-(C-x x) into a Dired directory buffer, Dired starts 
  80. ; again and you have it's commands at your disposal. If you should 
  81. ; find yourself back in a Dired-buffer which is not responding to
  82. ; Dired commands such as happens when you split the screen by "o"
  83. ; (view-file-other-window) or "t" (tar-view) on a .tar file, just 
  84. ; type C-x C-d to restart the Dired command processor in the window.
  85. ;
  86. ; I prefer C-x k to delete the current buffer and replace 
  87. ; with the next on the stack like GNUEmacs, so I have the 
  88. ; macro "kill-this-one" bound to C-x k, in my .emacsrc. 
  89. ; If you like it, do the same, and Dired will process it. Otherwise,
  90. ; you can comment out the !if..."kill-this-one" loop out (or leave it).
  91. ;
  92. ; ***************************************************************
  93. ;store-procedure kill-this-one
  94. ;   set %thisone $cbufname
  95. ;   set %ans @&cat &cat "Delete [" %thisone "]: "
  96. ;   !if &seq %ans ""
  97. ;      !force next-buffer
  98. ;      !force delete-buffer %thisone
  99. ;   !else
  100. ;      !force delete-buffer %ans
  101. ;   !endif
  102. ;!endm
  103. ;
  104. ;macro-to-key kill-this-one ^XK
  105. ; ****************************************************************
  106. ;
  107. ; Below is the list of Dired commands, executed singly when the cursor is
  108. ; on a file name and no files are marked (*ed), or executed on the 
  109. ; *ed files en masse:
  110. ; Movement:
  111. ;
  112. ;      arrow keys: up and down  (seem to work for me)
  113. ;            P, N: up, down respectively
  114. ;            k, j: up, down respectively
  115. ;    q-PgUpKey, V: Page-up
  116. ;    q-PgDnKey, B: Page-down
  117. ;
  118. ;   A note about movement keys: the V and B above are delivered on some
  119. ;   machines as the ***key*** entered when hitting PgUp and PgDn. The
  120. ;   ***cmd*** is still (previous/next-page). Hence, your PgUp/Dn keys
  121. ;   may work just as keys, or you may have to prefix them with the 
  122. ;   Dired-META "q" ie. q-PgUp... Failing that you can just enter "V"
  123. ;   or "B". The same applies to the arrow keys. Mine seem to work with
  124. ;   P and N, however k and j (like vi) are supplied in case yours don't.
  125. ;   
  126. ;  (If you feel like recompiling, Richard Meitzler, Stratus Computer, Marlboro, 
  127. ;   MA, [rgm@hw.stratus.com] has had some success fixing unix.c in the memacs
  128. ;   source to interpret the Sun/Sparc function keys.)
  129. ;
  130. ; Commands: 
  131. ;   f --- load file/directory into current window
  132. ;
  133. ;   o --- load file/directory into another window
  134. ;
  135. ;  m,d -- mark file   (with %markstr)
  136. ;
  137. ;   u --- unmark file
  138. ;
  139. ;   c --- copy (marked) file(s) 
  140. ;
  141. ;   r --- rename or move (marked) file(s)
  142. ;
  143. ;   x --- delete (marked) file(s)  [you're prompted; prompting can be turned off]
  144. ;
  145. ;   C --- compress ...
  146. ;
  147. ;   U --- uncompress ...
  148. ;
  149. ;   e --- extract tar file
  150. ;
  151. ;   t --- on a .tar archive, view contents in other window
  152. ;     --- or tar (marrked) file(s) into an archive
  153. ;            (must be viewing directory from which MicroEMACS
  154. ;             was invoked, ie. default directory at startup
  155. ;             so that files in tar file are portable---with no paths)
  156. ;
  157. ;   a --- execute file (useful for .cmd files; doesn't always work)
  158. ;
  159. ;   z --- leave dired processor (Dired-buffer becomes like any other)
  160. ;
  161. ;   Note that file or directory inputs to Dired are globbed 
  162. ;   so that ~/filename is expanded using you $HOME variable
  163. ;   (only ~/ is expanded though).
  164. ;
  165. ;   Filenames and directories entered for copy, move, etc., are processed
  166. ;   as follows: a single name gets the currently viewed directory prepended 
  167. ;   to it. If the filename/dir is entered with "/"'s in it, it's assumed 
  168. ;   that it represents a full pathname and left alone. ".." is a valid 
  169. ;   directory and will be expanded relative to the viewed directory.
  170. ;
  171. ;   C-x C-f (find-file) while in a some directory, opens a (new) file in that
  172. ;   directory.
  173. ;
  174. ;
  175. ;========================== Dired ======================================
  176.  
  177. ; Feel free to comment out this one:
  178. write-message " -\|/-   Dired <1.1-Unix> for MicroEMACS === 1992 (c) J. E. Hetrick   >> C-x d"
  179.  
  180. set %marked 0
  181. set %revert FALSE
  182. set %dot FALSE
  183. set %othwin FALSE
  184. set %dirowin FALSE
  185. set %comseq "q"        ; for command sequnce input (see D-getcmd)
  186. set %markstr " * "     ; must be 3 chars
  187. set %home &env "HOME"   ; for globbing
  188.  
  189. ;                                           =======D-check
  190. store-procedure D-check
  191.    !if &seq &left $cbufname 6 "Dired-"
  192.        set $discmd FALSE
  193.        set %length &len $cbufname
  194.        set %dir &rig $cbufname &sub %length 6
  195.        set %Dbuffer &cat "Dired-" %dir
  196.        change-file-name " "
  197.        beginning-of-file
  198.        set %starred FALSE
  199.        set %marked 0
  200.        !while &seq %starred FALSE
  201.           !force search-forward %markstr
  202.           !if &seq $status TRUE
  203.              set %marked &add %marked 1
  204.           !else 
  205.              set %starred TRUE
  206.           !endif
  207.        !endwhile
  208.        unmark-buffer %Dbuffer
  209.        beginning-of-file
  210.        !force search-forward ".."
  211.        set %ncol &sub $curcol 2
  212.        next-line
  213.        beginning-of-line
  214.        !force %ncol forward-character
  215.        set %filename " "      
  216.        set $discmd TRUE
  217.        D-process
  218.    !endif
  219. !endm
  220.  
  221. ;                                     ==============D-open
  222. store-procedure D-open
  223.       set $discmd FALSE
  224.       !if &seq %rcfkeys TRUE
  225.          !force toggle-fkeys
  226.       !endif
  227.       pipe-command "pwd"
  228.       beginning-of-file
  229.       set %cwd #command
  230.       set %dir @&cat &cat "Directory [" %cwd "]: "
  231.       !if &seq %dir "ERROR"
  232.          write-message "Aborting..."
  233.          delete-window
  234.          delete-buffer "command"
  235.          !return
  236.       !endif
  237.       delete-window
  238.       set $discmd TRUE
  239.       !if &sequal %dir ""
  240.          set %dir %cwd
  241.       !else 
  242.          !if &seq &left %dir 2 "~~/"
  243.             set %dir &cat %home &right %dir &sub &len %dir 1
  244.          !endif
  245.       !endif
  246.       D-window
  247. !endm
  248.  
  249. ;                                         =========D-window
  250. store-procedure D-window
  251.       !if &seq %revert FALSE
  252.          write-message &cat &cat "[Reading " %dir "...]
  253.       !endif
  254.       pipe-command &cat "ls -al " %dir
  255.       !if &seq %othwin FALSE
  256.          delete-other-windows
  257.       !endif
  258.       set %othwin FALSE
  259.       !if &seq %dirowin TRUE
  260.          set %dirowin FALSE
  261.      save-window
  262.      next-window
  263.          delete-window
  264.          restore-window
  265.       !endif
  266.       !force delete-buffer "stale"
  267.       set %rcfkeys FALSE
  268.       delete-mode "View"
  269.       set %Dbuffer &cat "Dired-" %dir
  270.       name-buffer %Dbuffer
  271.       change-file-name " "
  272.       beginning-of-file
  273.       set-mark
  274.       end-of-file
  275.       set %tabno $hardtab
  276.       set $hardtab 3
  277.       indent-region
  278.       detab-region
  279.       set $hardtab %tabno 
  280.       beginning-of-file
  281.       unmark-buffer %Dbuffer
  282.       !if &seq %revert TRUE
  283.          goto-line %oldline
  284.          set %revert FALSE
  285.       !else
  286.          !force search-forward ".."
  287.          set %ncol &sub $curcol 2
  288.          next-line
  289.       !endif
  290.       beginning-of-line
  291.       !force %ncol forward-character
  292.       set %filename " "      
  293.       set $discmd TRUE
  294.       D-process
  295. !endm
  296.  
  297. ;                                     ==============D-getcmd
  298. store-procedure D-getcmd
  299.    !if &seq $pending FALSE
  300.       !force update-screen
  301.    !endif
  302.    set %cmd " "    
  303.    set %key >key
  304.    !if &seq %key %comseq 
  305.       write-message "Command sequence:"
  306.       set %cmd >cmd
  307.       set %cmd &bind %cmd
  308.       write-message %cmd
  309.    !endif
  310. !endm
  311.  
  312. ;                                     ==============D-process
  313. store-procedure D-process   
  314.   write-message "Dired ON"
  315.   set $discmd FALSE
  316.   set %done FALSE
  317.   !while &seq %done FALSE
  318.   D-getcmd
  319.  
  320. ;======Movement======
  321.      !if &or &or &seq %key "k" &seq %key "P" &seq %cmd "previous-line"
  322.          !force previous-line
  323.          beginning-of-line
  324.          !force %ncol forward-character
  325.          !goto endproc
  326.      !endif
  327.  
  328.      !if &or &seq %key "B" &seq %cmd "previous-page"
  329.          !force previous-page
  330.          beginning-of-line
  331.          !force %ncol forward-character
  332.          !goto endproc
  333.      !endif
  334.  
  335.      !if &or &or &seq %key "j" &seq %key "N" &seq %cmd "next-line"
  336.          !force next-line
  337.          beginning-of-line
  338.          !force %ncol forward-character
  339.          !goto endproc
  340.       !endif
  341.  
  342.      !if &or &seq %key "V" &seq %cmd "next-page"
  343.          !force next-page
  344.          beginning-of-line
  345.          !force %ncol forward-character
  346.          !goto endproc
  347.       !endif
  348.  
  349. ; ======Edit file====== ---"f"---
  350.       !if &or &seq %key "f" &seq %cmd "mouse-region-down" 
  351.          D-getfile
  352.          D-load-file
  353.       !endif
  354.  
  355. ; ======Edit file other window====== ---"o"---
  356.       !if &seq %key "o"
  357.          set %othwin TRUE
  358.          2 split-current-window
  359.          D-getfile
  360.          !if &seq %dirq "d"
  361.         set %dirowin TRUE
  362.      !endif
  363.          D-load-file
  364.       !endif
  365.  
  366. ; ======Copy file======= ---"c"---
  367.       !if &seq %key "c"
  368.          D-getfile
  369.          !if &gre %marked 0
  370.             set %copy @"Copy marked files to: "
  371.             !if &seq %copy ".."
  372.                set %copy &cat %dir "/.."
  373.           !endif
  374.             !if &seq &left %copy 2 "~~/"
  375.                set %copy &cat %home &right %copy &sub &len %copy 1
  376.             !else
  377.                !if &equ &sind %copy "/" 0
  378.                   set %copy &cat &cat %dir "/" %copy
  379.                !endif
  380.             !endif
  381.             set %count 0
  382.             !while &gre %marked 0
  383.                beginning-of-file
  384.                search-forward %markstr
  385.                3 delete-previous-character
  386.                insert-string "   "
  387.                set %marked &sub %marked 1
  388.                D-getfile
  389.                shell-command &cat &cat &cat "cp " %filename " " %copy
  390.                set %count &add %count 1
  391.             !endwhile
  392.             write-message &cat %count " files copied"
  393.          !else
  394.             set %copy @&cat &cat "Copy  " %shortfile " to: "
  395.             !if &seq %copy ".."
  396.                set %copy &cat %dir "/.."
  397.           !endif
  398.             !if &seq &left %copy 2 "~~/"
  399.                set %copy &cat %home &right %copy &sub &len %copy 1
  400.             !else
  401.                !if &equ &sind %copy "/" 0
  402.                   set %copy &cat &cat %dir "/" %copy
  403.                !endif
  404.             !endif
  405.             shell-command &cat &cat &cat "cp " %filename " " %copy
  406.          !endif
  407.          D-revert
  408.          !break
  409.       !endif
  410.  
  411. ; ======Delete file(s)== ---"x"---
  412.       !if &seq %key "x"
  413.          !if &gre %marked 0
  414.             set %count 0
  415.             !while &gre %marked 0
  416.                beginning-of-file
  417.                search-forward %markstr
  418.                3 delete-previous-character
  419.                insert-string "   "
  420.                set %marked &sub %marked 1
  421.                D-getfile
  422. ; comment this set-if-loop out for no-prompt deletion of marked files
  423.                set %delq @&cat &cat "Delete  " %filename "? [y/n]: "
  424.                !if &seq &low %delq "y"
  425.                   D-delete
  426.                !endif
  427.                set %count &add %count 1
  428.             !endwhile
  429.             write-message &cat %count " files deleted"
  430.          !else
  431.             D-getfile
  432. ; comment this set-if-loop out for no-prompt deletion of file
  433.             set %delq @&cat &cat "Delete  " %filename "? [y/n]: "
  434.             !if &seq &low %delq "y"
  435.                D-delete
  436.             !else
  437.                write-message "No files deleted"
  438.             !endif
  439.          !endif
  440.          beginning-of-line
  441.          !force %ncol forward-character
  442.          set %delq " "
  443.          !goto endproc
  444.       !endif
  445.  
  446. ; ======Move file======= ---"r"---
  447.       !if &seq %key "r"
  448.          !if &gre %marked 0
  449.             set %move @"Move marked files to: "
  450.             !if &seq %move ".."
  451.                set %move &cat %dir "/.."
  452.           !endif
  453.             !if &seq &left %move 2 "~~/"
  454.                set %move &cat %home &right %move &sub &len %move 1
  455.             !else
  456.                !if &equ &sind %move "/" 0
  457.                   set %move &cat &cat %dir "/" %move
  458.                !endif
  459.             !endif
  460.             set %count 0
  461.             !while &gre %marked 0
  462.                beginning-of-file
  463.                search-forward %markstr
  464.                3 delete-previous-character
  465.                insert-string "   "
  466.                set %marked &sub %marked 1
  467.                D-getfile
  468.            shell-command &cat &cat &cat "mv -i " %filename " " %move
  469.                set %count &add %count 1
  470.             !endwhile
  471.             write-message &cat %count " files moved"
  472.          !else
  473.             D-getfile
  474.             set %move @&cat &cat "Move or Rename" %shortfile " to: "
  475.             !if &seq %move ".."
  476.                set %move &cat %dir "/.."
  477.           !endif
  478.             !if &seq &left %move 2 "~~/"
  479.                set %move &cat %home &right %move &sub &len %move 1
  480.             !else
  481.                !if &equ &sind %move "/" 0
  482.                   set %move &cat &cat %dir "/" %move
  483.                !endif
  484.             !endif
  485.             shell-command &cat &cat &cat "mv -i " %filename " " %move
  486.             unmark-buffer %Dbuffer
  487.          !endif
  488.          D-revert
  489.          !break
  490.       !endif
  491.  
  492. ; =======Mark File====== ---"m"---
  493.       !if &or &seq %key "m" &seq %key "d"
  494.          beginning-of-line
  495.          set %markq &left #%Dbuffer 3
  496.          previous-line
  497.          beginning-of-line
  498.          !if &seq %markq %markstr
  499.             write-message "file already marked"
  500.          !else   
  501.             !force 3 forward-character
  502.             3 delete-previous-character
  503.             insert-string %markstr
  504.             set %marked &add %marked 1
  505.             !if ¬ &equ $curline %lastline
  506.                next-line
  507.             !endif
  508.             beginning-of-line
  509.             !force %ncol forward-character
  510.             write-message &cat %marked " marked files"
  511.             unmark-buffer %Dbuffer
  512.          !endif
  513.          !goto endproc
  514.       !endif         
  515.  
  516. ; =======Unmark file===== ---"u"---
  517.       !if &seq %key "u"
  518.          beginning-of-line
  519.          set %markq &left #%Dbuffer 3
  520.          previous-line
  521.          beginning-of-line
  522.          !if &seq %markq "   "
  523.             write-message "file not marked"
  524.          !else   
  525.             3 forward-character
  526.             3 delete-previous-character
  527.             insert-string "   "
  528.             set %marked &sub %marked 1
  529.             beginning-of-line
  530.             next-line
  531.             !force %ncol forward-character
  532.             write-message &cat %marked " marked files"
  533.             unmark-buffer %Dbuffer
  534.          !endif
  535.          !goto endproc
  536.       !endif         
  537.  
  538. ; =======Revert Buffer===== ---"g"---
  539.       !if &seq %key "g"
  540.          D-revert
  541.          !break
  542.       !endif
  543.  
  544. ; =======Make Sub-Directory===== ---"+"--- 
  545.       !if &seq %key "+"
  546.          set %mkdir @&cat &cat "Make sub-directory: " %dir "/"
  547.      shell-command &cat &cat &cat "mkdir " %dir "/" %mkdir
  548.          D-revert
  549.          !break
  550.       !endif
  551.  
  552. ; =======Execute file===== ---"a"---
  553.       !if &seq %key "a"
  554.          D-getfile
  555.          set %done TRUE
  556.          execute-file %filename
  557.          !break
  558.       !endif
  559.  
  560. ; =======Compress===== ---"C"---    
  561.       !if &seq %key "C"
  562.          !if &gre %marked 0
  563.             set %compq @"Compress marked files? [y/n]: "
  564.             !if &seq &low %compq  "y"
  565.            write-message "uncompressing marked files..."
  566.                set %count 0
  567.                !while &gre %marked 0
  568.                   beginning-of-file
  569.                   search-forward %markstr
  570.                   D-getfile
  571.                   shell-command &cat "compress " %filename
  572.                   beginning-of-line
  573.                   3 forward-character
  574.                   3 delete-previous-character
  575.                   insert-string "   "
  576.                   set %marked &sub %marked 1
  577.                   set %count &add %count 1
  578.                !endwhile
  579.                write-message &cat %count " files compressed"
  580.             !endif
  581.          !else
  582.             D-getfile
  583.             set %compq @&cat &cat "Compress " %filename "? [y/n]: "
  584.             !if &seq &low %compq "y"
  585.                shell-command &cat "compress " %filename 
  586.             !endif
  587.          !endif
  588.          set %compq " "
  589.          D-revert
  590.          !break
  591.       !endif
  592.  
  593. ; =======Un-Compress===== ---"U"---    
  594.       !if &seq %key "U"
  595.          !if &gre %marked 0
  596.             set %compq @"Uncompress marked files? [y/n]: "
  597.         !if &seq &low %compq  "y"
  598.            write-message "uncompressing marked files..."
  599.                !while &gre %marked 0
  600.                   beginning-of-file
  601.                   search-forward %markstr
  602.                   D-getfile
  603.                   shell-command &cat "uncompress " %filename
  604.                   beginning-of-line
  605.                   3 forward-character
  606.                   3 delete-previous-character
  607.                   insert-string "   "
  608.                   set %marked &sub %marked 1
  609.                !endwhile
  610.             !endif
  611.          !else
  612.             D-getfile
  613.             set %compq @&cat &cat "Uncompress " %filename "? [y/n]: "
  614.             !if &seq &low %compq "y"
  615.                shell-command &cat "uncompress " %filename 
  616.             !endif
  617.          !endif
  618.          set %compq " "
  619.          D-revert
  620.          !break
  621.       !endif
  622.  
  623. ; =======Tar===== ---"t"---
  624.       !if &seq %key "t"
  625.      D-getfile
  626.      !if &seq &right %filename 4 ".tar"
  627.         D-tarview
  628.         !break
  629.      !else          
  630.             !if ¬ &seq %cwd %dir
  631.                write-message &cat "Abort: must be in " %cwd
  632.                !goto endtar
  633.             !endif
  634.             !if &gre %marked 0
  635.                set %tarc @"new archive name (.tar added)? : "
  636.                !if &seq &left %tarc 2 "~~/"
  637.                   set %tarc &cat %home &right %tarc &sub &len %tarc 1
  638.                !else
  639.                   !if &equ &sind %tarc "/" 0
  640.                      set %tarc &cat &cat %dir "/" %tarc
  641.                   !endif
  642.                !endif
  643.                set %tarc &cat %tarc ".tar"
  644.                write-message &cat &cat "Tarring marked files into " %tarc "..."
  645.                set %count 0
  646.                !while &gre %marked 0
  647.                   beginning-of-file
  648.                   search-forward %markstr
  649.                   D-getfile
  650.                   beginning-of-line
  651.                   3 forward-character
  652.                   3 delete-previous-character
  653.                   insert-string "   "
  654.                   shell-command &cat &cat "echo " %shortfile " >> TARLIST"
  655.                   set %marked &sub %marked 1
  656.                   set %count &add %count 1
  657.                !endwhile
  658.                set %marked 0
  659.                shell-command &cat  &cat "tar cf " %tarc " -I TARLIST"
  660.                shell-command "rm TARLIST"
  661.                write-message &cat &cat %count " files tarred in " %tarc
  662.             !else
  663.                D-getfile
  664.                set %tarc &cat &cat &cat %dir "/" %filename ".tar"
  665.                write-message &cat &cat "Tarring " %shortfile "..."
  666.                shell-command &cat &cat "tar cf " %tarc %shortname
  667.             !endif
  668.          !endif
  669.          D-revert
  670.          !break
  671.          *endtar
  672.       !endif
  673.  
  674. ; =======Un-Tar===== ---"e"---
  675.       !if &seq %key "e"
  676.          !if ¬ &seq %cwd %dir
  677.             write-message &cat "Abort: Files would be extracted into " %cwd
  678.             !goto enduntar
  679.          !endif
  680.      D-getfile
  681.          write-message &cat &cat "Extracting " %shortfile "..."
  682.      shell-command &cat "tar xf " %filename
  683.          D-revert
  684.          !break
  685.          *enduntar
  686.        !endif
  687.  
  688. ; =======Exit Dired Mode ---"z"---
  689.       !if &seq %key "z"
  690.      write-message "Dired OFF... (C-x C-d to resume)"
  691.          set %done TRUE
  692.          !break
  693.       !endif               
  694.  
  695. ; =======Find file===== C-x C-f
  696.       !if &seq %cmd "find-file"
  697.          set %cmd " "
  698.          set %newbuf @"Find file: "
  699.          !if &seq &left %newbuf 2 "~~/"
  700.             set %newbuf &cat %home &right %newbuf &sub &len %newbuf 1
  701.          !else
  702.             !if &equ &sind %newbuf "/" 0
  703.                set %newbuf &cat &cat %dir "/" %newbuf
  704.             !endif
  705.          !endif
  706.          !force find-file %newbuf
  707.          set %done TRUE
  708.          !break
  709.       !endif               
  710.  
  711. ; =======Pass commands=====
  712.       !if &seq %cmd "delete-buffer"
  713.          set %done TRUE
  714.          next-buffer
  715.          delete-buffer %Dbuffer
  716.       !endif
  717.  
  718.       !if &seq %cmd "[D-open]"
  719.          !force D-open
  720.       !endif      
  721.  
  722.       !if &seq %cmd "[mouse-clicks]"
  723.          !force mouse-move-down
  724.          !goto endproc
  725.       !endif      
  726.  
  727.       !if &seq %cmd "[toggle-fkeys]"
  728.          execute-procedure "toggle-fkeys"
  729.          !goto endproc
  730.       !endif      
  731.  
  732.       !if &seq %cmd "[get-help]"
  733.          execute-procedure "get-help"
  734.          !goto endproc
  735.       !endif      
  736.  
  737.       !if &seq %cmd "next-buffer"
  738.          set %done TRUE
  739.          unmark-buffer %Dbuffer
  740.          next-buffer
  741.          !goto endproc
  742.       !endif      
  743.  
  744.       !if &seq %cmd "[kill-this-one]"
  745.          set %done TRUE
  746.          set %cmd " "
  747.          execute-procedure kill-this-one
  748.          !goto endproc
  749.       !endif      
  750.  
  751.       !force execute-named-command %cmd
  752.  
  753.       *endproc
  754.    !endwhile
  755. !endm
  756.  
  757. ;                                     ==============D-getfile
  758. store-procedure D-getfile
  759.    end-of-line
  760.    !if &les $curcol %ncol
  761.       write-message "Not positioned on file or directory"
  762.       !goto endget
  763.    !endif
  764.    beginning-of-line
  765.    3 forward-character
  766.    set %dirq &left #%Dbuffer 1
  767.    previous-line
  768.    beginning-of-line
  769.    !force %ncol forward-character
  770.    set %filename &trim #%Dbuffer
  771.    !if &seq %dirq "d"
  772.       !if &seq %filename "."
  773.          write-message "Tried to load ~".~" (use g to revert buffer to refresh)"
  774.          previous-line
  775.          !force %ncol forward-character
  776.          set %dot TRUE
  777.          !goto endget
  778.       !endif
  779.       !if &seq %filename ".."
  780.          set %testdir %dir
  781.          set %orgdir %testdir
  782.          set %dirlen &len %testdir
  783.          set %orglen %dirlen
  784.          set %slash &sind %testdir "/"
  785.          !while ¬ &equ %slash 0
  786.             set %testdir &right %testdir &sub %dirlen %slash
  787.             set %dirlen &len %testdir
  788.             set %slash &sind %testdir "/"
  789.          !endwhile
  790.          write-message &left %orgdir &sub %orglen &add 1 &len %testdir
  791.          set %newdir &left %orgdir &sub %orglen &add 1 &len %testdir
  792.       !else
  793.          set %newdir &cat &cat %dir "/" %filename
  794.       !endif
  795.    !else
  796.       set %shortfile %filename
  797.       set %filename &cat &cat %dir "/" %filename
  798.       set %dirq " "
  799.    !endif
  800.    previous-line
  801.    !force %ncol forward-character
  802.    *endget
  803. !endm 
  804.    
  805. ;                                     ==============D-load-file
  806. store-procedure D-load-file
  807. !if &seq %dot FALSE
  808.    !if &seq %dirq "d"
  809.       !force delete-buffer &cat "Dired-" %newdir
  810.       set %dirq " "
  811.       set %dir %newdir
  812.       !if %revert FALSE
  813.          write-message &cat &cat "[Reading " %dir "...]"
  814.       !endif
  815.       set %done TRUE
  816.       D-window
  817.    !else
  818.       write-message &cat &cat "[Reading " %filename "...]"
  819.       !if &seq %othwin FALSE
  820.          delete-other-windows
  821.       !else
  822.          set %othwin FALSE
  823.       !endif
  824.       !force find-file %filename
  825.       set %done TRUE
  826.    !endif
  827. !endif
  828.    set %dot FALSE
  829.    *loadend
  830. !endm
  831.  
  832.  
  833. ;                                     ==============D-delete
  834. store-procedure D-delete
  835.    write-message &cat &cat "Deleting  " %filename "..."
  836.    shell-command &cat &cat "rm " %filename
  837.    beginning-of-line
  838.    1 kill-to-end-of-line
  839.    set %lastline &sub %lastline 1
  840.    update-screen
  841.    unmark-buffer %Dbuffer
  842. !endm
  843.  
  844. ;                                     ==============D-tarview
  845. store-procedure D-tarview 
  846.    set %cmd " "
  847.    !force pipe-command &cat "tar tvf " %filename
  848.    set %done TRUE
  849.    name-buffer %shortfile
  850.    change-file-name "tar-view"
  851.    beginning-of-file
  852.    insert-string &cat &cat "=== Contents of tarfile: " %shortfile " ===~n~n"
  853.    update-screen
  854. !endm
  855.  
  856. store-procedure D-revert
  857.   set %revert TRUE
  858.   set %oldline $curline
  859.   name-buffer "stale"
  860.   unmark-buffer "stale"
  861.   D-window
  862. !endm
  863.  
  864. set $discmd FALSE
  865. macro-to-key D-open ^XD
  866. macro-to-key D-check ^X^D
  867. set $bufhook D-check
  868. set $discmd TRUE
  869. ;write-message "...done   (C-x d to open directory)"
  870.