Next: dired-cd.el Prev: Letting Dired Guess What Shell Command to Apply Up: Tree Dired Extra
Filename Transformers for Dired Shell Commands
File name "transformers" are functions that take a filename (a
string) as an argument and transform it into some other string (e.g., a
filename without an extension). This package makes transformers
available in Dired shell commands.
For example, running the Dired shell command (type `!' or `M-x'
echo * [b] [db]
would list the full name, the basename, and the absolute basename of
each marked file.
Each transformer is associated with a dispatch character. The
associations are stored in a keymap for fast and easy lookup. The
dispatch character is used to activate the associated transformer
function at a particular position in a shell command issued in Dired.
The dispatch character must be enclosed in brackets to distinguish it
from normal letters.
To take advantage of this package, simply load it after loading
Dired, e.g., in your `dired-load-hook'. You can then use transformers
like "[b]" for the basename in your Dired shell commands (see below).
You can define your own transformers using the macro
Macro that assigns the transformer function `(lambda (file) BODY)'
to CHAR (a character or string). BODY must return a string: the
Several transformers are predefined:
returns the unmodified filename (equivalent to `[dbe]').
returns the Name component of a filename without directory
returns the Directory component of a filename
returns the Basename of a filename, i.e., the name of the file
without directory and extension (see variable `dired-trans-re-ext')
A basename with directory component can be obtained by `[db]'.
returns the Extension of a filename (i.e., whatever
`dired-trans-re-ext' splits off)
returns a file without directory and without `,v' suffixes if any.
returns a file without directory and without `.Z' suffixes if any.
The following variables can be used to customize `dired-trns.el':
The part of a filename matching this regexp will be viewed as
User definable set of characters to be used to indicate the start
of a transformer sequence.
Default: `"# ]"'
User definable set of characters to be used to indicate the end of
a transformer sequence.
automatically generated by info2www