[comp.emacs] directory editting

lord+@andrew.cmu.edu (Tom Lord) (09/17/87)

The following is the major mode help for a directory editor I wrote some
months ago.   It is good at carrying out operations on many files at a time.
It offers in-situ subdirectory expansion and corresponding outline-mode like
features.  It's called monkey-mode:  good for climbing around in trees.

The problem is that it is quite long (40k).  Is there sufficient interest to
justify my posting it here?


Thomas Lord
Information Technology Center
Carnegie Mellon University
Thomas.Lord@andrew.cmu.edu

Mode for "editing" directory listings.
In monkey, you are "editing" a list of the files in a directory.
You can move using the usual cursor motion commands.
Letters no longer insert themselves.

In monkey, you may operate on any number of files at a time.  You do
this by `marking' those files you are interested in.  If you do not
mark any files, then the file on the line containing the point is
considered `marked'.

The format of lines in a monkey buffer is important.  It consists of three
fields:
<markfield><typefield> <filename>.  The markfield is empty for unmarked
files, and
is a `+' for marked files.  The typefield contains a character describing the
type 
of the file: `/' for directories, `@' for symbolic links, `*' for
executables, `,' for
character devies, and `$' for block devices. For example, a marked directory
named `foo'
would look like

+/ foo

while an unmarked text file named `bar' would look like:

   bar


The monkey-mode commands are summarized below.  There are many intuitive
aliases for
the more common commands (for example, `+' is an alias for `m' to mark the
current file).
These aliases are not summarized below.

Basic movement commands:
n 	move down one line.
SPACE	move down one line.
p	move up one line.

Note: with a prefix arg, all movement commands iterate.


Basic marking commands:

Note: with a prefix arg, all marking commands become
unmarking commands, and vice versa.  Also, ESC is a general
prefix meaning `do this to everything'.

RET	mark this file.
u	unmark this file.
DEL	unmark and move backwards.
t	toggle this mark.
ESC m	mark everything
ESC u	unmark everything
ESC t	toggle all marks
~	mark all backup files.
#	mark all check point files.
.	mark all `dot' files.
@	mark all symbolic links.
*       mark all executables.
/	mark all directories.
k	mark files by typefield.
	(e.g. k/ is an alias for /)


Basic Operations on marked files:
e	edit.
v	edit and trash this buffer.
o	edit in the other window.
l	show a long directory listing.
c	copy (this can take a dir as destination).
r	rename.
d	delete.
]	shove the marked filenames into a scratch buffer.


Subdirectory commands:
s	expand in-situ marked subdirectories.
C-us	unexpand marked subdirectories.
C-cC-s	mark this subdirectory.
C-uC-cC-s unmark this subdirectory. (remember the rule about marking 
		commands and prefix args?)
C-cC-f 	move past this subdirectory.
C-cC-b	move before this subdirectory.
C-cC-n	move forward skipping subdirectories.
C-cC-p	move backward skipping subdirectories.
ESC n	move to the next directory.
ESC p 	move to the previous directory.
C-c^	move to the directory line for this subdir.

Hiding commands:
h	hide all marked files.
	With a prefix are, unhide hidden files near the point.
ESC h	unhide all hidden files.

Regexp commands:
C-cC-m	mark files matching a regexp.
C-cu	unmark files matching a regexp.
C-cc	copy by regexp (see below).
C-cr	rename by regexp.
x       mark files matching .*\.REGEXP.  REGEXP is prompted for.
        (i.e. x o <RET> marks all object files)

Copying and renaming by regexp is an unusual feature.  It is useful
for operating on groups of files, when the name changes are regular. 
For example, suppose that in some directory, I have a group of files with
names like m-sun.h, m-ibmrt.h etc., and I wish to move them all to a
directory
called `machines', stripping them of the `m-' affix in the process.  Then I
would 
1) Mark them using `C-cm m-\(.*\) RET'
2) Rename them using `C-cr machines/\1 RET'

Pretty cool, huh?

Misc commands:
g	use this when you find yourself saying `Gee, that can't be right!'
^	edit the parent of this directory."