jprefixmatch.tcl
The
jprefixmatch.tcl library is distributed as part of the
jstools package. It contains procedures to do prefix expansion like
that done for filename completion by
tcsh(1) and Emacs, or for command disambiguation under VMS.
This document describes
jprefixmatch.tcl version 4.1/4.4.
Accessing the Library
In order to use the
jprefixmatch.tcl library, it (and any other libraries it depends on) must be
in your Tcl
auto_path, described in
tclvars(n). Information about how to arrange that, and other conventions
common to
the
jstools libraries, is in
the
Usage section of
The jstools Libraries.
Author
Jay Sekora
js@aq.org
http://www.aq.org/~js/
Copyright
The library is copyright © 1992-1995 by Jay Sekora, but may be
freely redistributed under the conditions at the top of the file.
Procedures
j:longest_match - find the longest common initial string in a list
j:expand_filename - expand filename prefix as much as possible
Usage
j:longest_match
l
Argument
l - list of strings
Description
This procedure finds and returns the longest common initial string
in list
l. If there's no common initial string, it returs the empty
list
{}. It's used by
j:expand_filename for filename completion, but could also be used for things
like handling abbreviations.
Usage
j:expand_filename
f
Argument
f - initial filename prefix to be expanded
Description
This procedure tries to do filename completion on the prefix
f, as in Emacs and
tcsh. It returns the longest initial substring common to those
filenames in the current directory that match
f. It also can be used for globbing; if
f contains globbing metacharacters (`*', `?', initial `~', or `[...]'), they will be expanded as in the shell.
Bugs and Limitations
* The expansion of globbing metacharacters, while occasionally
useful, is unlikely to be intuitive to a user. (You might want
to check for these in your code before calling
j:expand_filename.)